Reputation: 11
Recently, I'm reading the libc-init code of android. When I read the code in malloc_debug_leak.cpp
, line 70 and line 263, it said as follows.
#define GUARD 0x48151642
static uint32_t MEMALIGN_GUARD = 0xA1A41520;
I know the GUARD
and MEMALIGN_GUARD
meaning, but I really don't get the meaning of the value, for example static uint32_t MEMALIGN_GUARD = 0x0001
is OK?or any other value. Does 0xA1A41520
have some useful info?
https://i.sstatic.net/9lgzv.png
https://i.sstatic.net/ZMM5u.png
Upvotes: -1
Views: 129
Reputation: 213877
I really don't get the meaning of the value
It's a magic value, intended to catch common programming mistakes. See this wikipedia article for detailed explanation.
Would
0x0001
be OK?
No. It lacks the "distinctive unique value that is unlikely to be mistaken for other meanings" property.
When you see value 0x1
in a certain location memory, such value could very likely be placed there by lots of different code sequences. On the other hand, when you see 0xA1A41520
, it is quite unlikely (though still possible) that that value was placed there by code other than the one that is using MEMALIGN_GUARD
.
Upvotes: 0