From c36352c17374b72d0a6c6b4cdc3a21a66380a4ef Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sat, 5 Jan 2002 19:38:54 +0000 Subject: [PATCH] Misc allocator cleanup --- libraries/liblber/lber-int.h | 16 +--------------- libraries/liblber/memory.c | 21 ++++----------------- libraries/libldap/ldap-int.h | 7 ------- 3 files changed, 5 insertions(+), 39 deletions(-) diff --git a/libraries/liblber/lber-int.h b/libraries/liblber/lber-int.h index 7933042bef..800f7444f5 100644 --- a/libraries/liblber/lber-int.h +++ b/libraries/liblber/lber-int.h @@ -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 ); #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_CALLOC calloc #define LBER_REALLOC realloc #define LBER_FREE free #define LBER_VFREE ber_memvfree #define LBER_STRDUP strdup -#define LBER_STRNDUP ber_strndup__ +#define LBER_STRNDUP ber_strndup__ #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_CALLOC(n,s) ber_memcalloc((n),(s)) #define LBER_REALLOC(p,s) ber_memrealloc((p),(s)) diff --git a/libraries/liblber/memory.c b/libraries/liblber/memory.c index cbf3f73041..de372348e0 100644 --- a/libraries/liblber/memory.c +++ b/libraries/liblber/memory.c @@ -112,19 +112,6 @@ static unsigned char endpattern[4] = { 0xd1, 0xed, 0xde, 0xca }; 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 ber_memfree( void *p ) { @@ -294,12 +281,12 @@ ber_memrealloc( void* p, ber_len_t s ) /* realloc(NULL,s) -> malloc(s) */ if( p == NULL ) { - return ber_memalloc( s ); + return LBER_MALLOC( s ); } /* realloc(p,0) -> free(p) */ if( s == 0 ) { - ber_memfree( p ); + LBER_FREE( p ); return NULL; } @@ -407,7 +394,7 @@ ber_bvecadd( struct berval ***bvec, struct berval *bv ) return 0; } - *bvec = ber_memalloc( 2 * sizeof(struct berval *) ); + *bvec = LBER_MALLOC( 2 * sizeof(struct berval *) ); if( *bvec == NULL ) { return -1; @@ -430,7 +417,7 @@ ber_bvecadd( struct berval ***bvec, struct berval *bv ) return i; } - new = ber_memrealloc( *bvec, (i+2) * sizeof(struct berval *)); + new = LBER_REALLOC( *bvec, (i+2) * sizeof(struct berval *)); if( new == NULL ) { return -1; diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index c9e98b3e0b..591c3e4e74 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -331,13 +331,6 @@ LDAP_F ( void ) ldap_int_initialize_global_options LDAP_P(( /* memory.c */ /* 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_CALLOC(n,s) (LBER_CALLOC((n),(s))) #define LDAP_REALLOC(p,s) (LBER_REALLOC((p),(s))) -- 2.39.5