WTF

Feb 23, 2009 16:01

Why does the BREW header file AEESTDLIB.H have this?

#define COMPRESSMEM() MALLOC(0xdeadbeef)

Leave a comment

Comments 3

zurmikopa February 24 2009, 05:36:45 UTC
I don't know for sure, but 0xdeadbeef is a common memory marker to check for things like memory overwrites and the like because it's easy to recognize (being the English words "dead beef") as well as valid hex.
So my guess is they were afraid of memory overwrites so they pre-filled it with that marker. (It also looks like their MALLOC macro includes both malloc and memset... fun...)

Reply

zurmikopa February 24 2009, 05:38:56 UTC
As an aside, the reason "deadbeef" is chosen instead of just 0s is a lot of times memory is initialized with zeros anyway, so if you're looking for overwrites or corruption, you want to pick something else.

As to why they define COMPRESSMEM to it, that I have no idea...

Reply

keless February 24 2009, 17:00:38 UTC
No, their MALLOC definately does not do any memory management. You have to use FREE.

I'm just hoping that a) this never gets used anywhere, and b) perhaps this is a magic number that causes MALLOC to perform an undocumented function.

Reply


Leave a comment

Up