[asterisk-dev] astmm.h info

Russell Bryant russell at digium.com
Fri Dec 21 09:47:00 CST 2007


Bhrugu Mehta wrote:
> Can anyone tell me why in astmm.h in asterisk 1.4.15 used  SOME_PRIME 563 and
> FENCE_MAGIC 0xdeadbeef .
> what is the use of this.

SOME_PRIME is the size of the hash table used to store the information about all
of the current memory allocations in Asterisk.

When an allocation is done through astmm, it allocates 8 extra bytes so that it
can put a 4-byte "fence" at the upper and lower limit of the allocated chunk of
memory.  That "fence" is set to the value FENCE_MAGIC.  Then, when the
allocation is free()'d, the value of the fence gets checked to see if someone
wrote before or after the memory they were supposed to.

-- 
Russell Bryant
Senior Software Engineer
Open Source Team Lead
Digium, Inc.



More information about the asterisk-dev mailing list