background image
Bionic Buffalo Tech Note #102: Using the Ivory Coast Memory Management Routines
An application can determine the values of the user flags associated with a specific block by calling the
procedure
    civ_status_T    civ_memory_flags_get
                            ( void            * pointer,
                            civ_flags_T       * flags ) ;
The flags value returned will contain the user flags as the least significant eight bits. The values of
other bits are not defined. The returned value can be masked by ANDing it with
CIV_MEMORY_FLAG_USER_VALUE_MASK
. If desired, the user flags can be modified and rewritten
to the block by calling
    civ_status_T    civ_memory_flags_set
                            ( void            * pointer,
                            civ_flags_T         flags ) ;
When 
civ_memory_flags_set()
 is called, none of the 
flags
 bits above the least significant
eight should be set. Otherwise, the consequences are unpredictable.
Checking Memory
An application can check a single block of memory for integrity using
    civ_status_T    civ_memory_validate_user_block
                            ( void            * pointer,
                            civ_flags_T         flags ) ;
This will verify the correct value of the canary (if any), and do some consistency checking on the
prefix.
By default, there is no way to check all of the blocks together, because the library doesn't keep a
master list of allocated blocks. However, if the library is built with the 
CIV_MEMORY_KEEP_CHAIN
flag set, then the library adds extra fields to the prefix to keep a linked list of all allocated blocks. In
that case,
    civ_status_T    civ_memory_validate_all
                            ( civ_flags_T       flags ) ;
can be called to check every allocated block. (The value of 
CIV_MEMORY_KEEP_CHAIN
 is defined
in the ivory coast header files.)
There is an additional routine defined by the library,
civ_memory_validate_system_block()
, which is used internally and should not be called
by applications.
Page 5 of 6