Misc allocator cleanup

This commit is contained in:
Kurt Zeilenga 2002-01-05 19:38:54 +00:00
parent c83b406fdc
commit c36352c173
3 changed files with 5 additions and 39 deletions

View File

@ -163,29 +163,15 @@ LBER_F (char *) ber_strndup( LDAP_CONST char *, ber_len_t );
LBER_F (char *) ber_strndup__( LDAP_CONST char *, size_t ); LBER_F (char *) ber_strndup__( LDAP_CONST char *, size_t );
#ifdef CSRIMALLOC #ifdef CSRIMALLOC
#define LBER_INT_MALLOC malloc
#define LBER_INT_CALLOC calloc
#define LBER_INT_REALLOC realloc
#define LBER_INT_FREE free
#define LBER_INT_VFREE ber_memvfree
#define LBER_INT_STRDUP strdup
#define LBER_MALLOC malloc #define LBER_MALLOC malloc
#define LBER_CALLOC calloc #define LBER_CALLOC calloc
#define LBER_REALLOC realloc #define LBER_REALLOC realloc
#define LBER_FREE free #define LBER_FREE free
#define LBER_VFREE ber_memvfree #define LBER_VFREE ber_memvfree
#define LBER_STRDUP strdup #define LBER_STRDUP strdup
#define LBER_STRNDUP ber_strndup__ #define LBER_STRNDUP ber_strndup__
#else #else
#define LBER_INT_MALLOC(s) ber_memalloc((s))
#define LBER_INT_CALLOC(n,s) ber_memcalloc((n),(s))
#define LBER_INT_REALLOC(p,s) ber_memrealloc((p),(s))
#define LBER_INT_FREE(p) ber_memfree((p))
#define LBER_INT_VFREE(v) ber_memvfree((void**)(v))
#define LBER_INT_STRDUP(s) ber_strdup((s))
#define LBER_MALLOC(s) ber_memalloc((s)) #define LBER_MALLOC(s) ber_memalloc((s))
#define LBER_CALLOC(n,s) ber_memcalloc((n),(s)) #define LBER_CALLOC(n,s) ber_memcalloc((n),(s))
#define LBER_REALLOC(p,s) ber_memrealloc((p),(s)) #define LBER_REALLOC(p,s) ber_memrealloc((p),(s))

View File

@ -112,19 +112,6 @@ static unsigned char endpattern[4] = { 0xd1, 0xed, 0xde, 0xca };
BerMemoryFunctions *ber_int_memory_fns = NULL; BerMemoryFunctions *ber_int_memory_fns = NULL;
#if 0 && defined( LDAP_MEMORY_DEBUG )
void
ber_int_memfree( void **p )
{
assert( p != NULL );
BER_MEM_VALID( *p );
ber_memfree( p );
*p = BER_MEM_BADADDR;
}
#endif
void void
ber_memfree( void *p ) ber_memfree( void *p )
{ {
@ -294,12 +281,12 @@ ber_memrealloc( void* p, ber_len_t s )
/* realloc(NULL,s) -> malloc(s) */ /* realloc(NULL,s) -> malloc(s) */
if( p == NULL ) { if( p == NULL ) {
return ber_memalloc( s ); return LBER_MALLOC( s );
} }
/* realloc(p,0) -> free(p) */ /* realloc(p,0) -> free(p) */
if( s == 0 ) { if( s == 0 ) {
ber_memfree( p ); LBER_FREE( p );
return NULL; return NULL;
} }
@ -407,7 +394,7 @@ ber_bvecadd( struct berval ***bvec, struct berval *bv )
return 0; return 0;
} }
*bvec = ber_memalloc( 2 * sizeof(struct berval *) ); *bvec = LBER_MALLOC( 2 * sizeof(struct berval *) );
if( *bvec == NULL ) { if( *bvec == NULL ) {
return -1; return -1;
@ -430,7 +417,7 @@ ber_bvecadd( struct berval ***bvec, struct berval *bv )
return i; return i;
} }
new = ber_memrealloc( *bvec, (i+2) * sizeof(struct berval *)); new = LBER_REALLOC( *bvec, (i+2) * sizeof(struct berval *));
if( new == NULL ) { if( new == NULL ) {
return -1; return -1;

View File

@ -331,13 +331,6 @@ LDAP_F ( void ) ldap_int_initialize_global_options LDAP_P((
/* memory.c */ /* memory.c */
/* simple macros to realloc for now */ /* simple macros to realloc for now */
#define LDAP_INT_MALLOC(s) (LBER_MALLOC((s)))
#define LDAP_INT_CALLOC(n,s) (LBER_CALLOC((n),(s)))
#define LDAP_INT_REALLOC(p,s) (LBER_REALLOC((p),(s)))
#define LDAP_INT_FREE(p) (LBER_FREE((p)))
#define LDAP_INT_VFREE(v) (LBER_VFREE((void **)(v)))
#define LDAP_INT_STRDUP(s) (LBER_STRDUP((s)))
#define LDAP_MALLOC(s) (LBER_MALLOC((s))) #define LDAP_MALLOC(s) (LBER_MALLOC((s)))
#define LDAP_CALLOC(n,s) (LBER_CALLOC((n),(s))) #define LDAP_CALLOC(n,s) (LBER_CALLOC((n),(s)))
#define LDAP_REALLOC(p,s) (LBER_REALLOC((p),(s))) #define LDAP_REALLOC(p,s) (LBER_REALLOC((p),(s)))