[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
malloc & free functions
I'm getting lost in all the malloc and free functions...
When is one supposed to use which function? When does it matter?
ber_memalloc(), ber_memfree(),
LBER_FREE(), LBER_MALLOC() -defined as the two above,
ber_memalloc_x(), ber_memfree_x() - as as above but with ctx parameter,
LDAP_FREE(), LDAP_MALLOC() plus _X variants,
ch_malloc, ch_free() - also as above,
slap_sl_malloc(), slap_sl_free() - separate slapd allocator.
E.g. liblber/decode.c often uses ber_memalloc_x(,ber->ber_memctx) to
allocate but then frees that memory with LBER_FREE() which does not
use a ctx. Should the free use ber->ber_memctx again? Or not, since
ber_set_option(,LBER_OPT_BER_MEMCTX,) can change a ber_memctx and
slapd uses it sometimes?
--
Hallvard
For sale: Parachute. Never opened, used once, slightly stained.