[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: free vs. ber_memfree

There are very few cases where free() should be called
directly (namely when the system library allocator was
used directly).  Generally, the *free() form used should match
the *alloc() form used.  That is, if ber_bvdup() is used
to allocate something, it needs to be freed using ber_*free().
If LDAP_*ALLOC(), then LDAP_FREE().  If LBER_*ALLOC(), then

For slapd, if ch_*alloc() is used, then ch_free() should be used.
Eventually, calls to ch_* routines will be replaced with macros
calling ber_* directly, PLUS code to handle memory errors.  Work
in this area is quite welcomed.

At 09:17 AM 2002-01-05, Pierangelo Masarati wrote:
>I'm experiencing some memory problems in HEAD code; I'm not able to track
>them with some efence or other tool because they seem to show up misleading
>errors. I also note that there might be an inconsistent use of free
>and ber_memfree in HEAD code which should be clarified (libraries also
>use LDAP_FREE and LBER_FREE which are macros that invoke the two
>functions depending on some CSRIMALLOC #define which I don't know about.
>Is there any documentation on how dynamic memory should be handled 
>throughout the package? 
>Thanks, Ando.