2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 BerMemoryFunctions *ber_int_memory_fns = NULL;
15 ber_memfree( void *p )
17 ber_int_options.lbo_valid = LBER_INITIALIZED;
19 /* catch p == NULL when debugging */
22 /* ignore p == NULL when not debugging */
27 if( ber_int_memory_fns == NULL ) {
32 assert( ber_int_memory_fns->bmf_free );
34 (*ber_int_memory_fns->bmf_free)( p );
38 ber_memalloc( size_t s )
40 ber_int_options.lbo_valid = LBER_INITIALIZED;
42 /* catch s == 0 when debugging */
45 /* ignore s == 0 when not debugging */
50 if( ber_int_memory_fns == NULL ) {
54 assert( ber_int_memory_fns->bmf_malloc );
56 return (*ber_int_memory_fns->bmf_malloc)( s );
60 ber_memcalloc( size_t n, size_t s )
62 ber_int_options.lbo_valid = LBER_INITIALIZED;
64 /* catch s,n == 0 when debugging */
67 /* ignore s,n == 0 when not debugging */
68 if( n == 0 || s == 0 ) {
72 if( ber_int_memory_fns == NULL ) {
73 return calloc( n, s );
76 assert( ber_int_memory_fns->bmf_calloc );
78 return (*ber_int_memory_fns->bmf_calloc)( n, s );
82 ber_memrealloc( void* p, size_t s )
84 ber_int_options.lbo_valid = LBER_INITIALIZED;
86 /* realloc(NULL,s) -> malloc(s) */
88 return ber_memalloc( s );
91 /* realloc(p,0) -> free(p) */
97 if( ber_int_memory_fns == NULL ) {
98 return realloc( p, s );
101 assert( ber_int_memory_fns->bmf_realloc );
103 return (*ber_int_memory_fns->bmf_realloc)( p, s );