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?
It's a magic value, intended to catch common programming mistakes. See this wikipedia article for detailed explanation.
No. It lacks the "distinctive unique value that is unlikely to be mistaken for other meanings" property.
When you see value
0x1in a certain location memory, such value could very likely be placed there by lots of different code sequences. On the other hand, when you see0xA1A41520, it is quite unlikely (though still possible) that that value was placed there by code other than the one that is usingMEMALIGN_GUARD.