Bionic Buffalo Tech Note #102: Using the Ivory Coast Memory Management Routines
In the current version of the library, the use of
civ_memory_validate_all()
and
CIV_MEMORY_FLAG_KEEP_CHAIN
is not thread safe.
Using the Memory Routines in Applications
The Ivory Coast library, and other libraries, use the memory allocation routines internally. Often, there
is no explicit way to set the memory allocation flags for calls such as
civ_string_duplicate()
.
However, the memory allocation routines refer to the global variable
civ_flags_T civ_memory_flags_default ;
during their operation. If any of the five library flags or eight user flags are set in this variable, then
they are applied to the calls made by the library or the application. For example, an application which
executes the statement
civ_memory_flags_default |= CIV_MEMORY_FLAG_CLEAR_ALLOCATED ;
will cause all subsequent memory allocations to zero the user blocks before returning to the caller.
Remember that the pointers returned or used by the
civ_memory_*()
routines are incompatible
with the pointers returned or used by
malloc()
,
free()
, and other standard library routines. This
includes standard routines such as
strdup()
, which allocates a buffer using
malloc()
. An
application using the Ivory Coast memory procedures should avoid such libary routines; instead, it
should use compatible procedures such as
civ_string_duplicate()
. , which allocate their
buffers using the
civ_memory_*()
procedures.
This Tech Note may be reproduced and distributed (including by means of the Internet) without
payment of fees or without notification to Bionic Buffalo, as long as it is not changed, altered, or
edited in any way. Any distribution or copy must include the entire Tech Note, with the original title,
copyright notice, and this paragraph. For available Tech Notes, please see the Bionic Buffalo web site
at http://www.tatanka.com/doc/technote/index.htm, or e-mail query@tatanka.com. PGP/GnuPG key
fingerprint:
a836 e7b0 24ad 3259 7c38 b384 8804 5520 2c74 1e5a
.
Page 6 of 6