]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/ch_malloc.c
misc cleanup
[openldap] / servers / slapd / ch_malloc.c
index 8084b7e2d0a0d8ed971588bb1412f4a3e2ac5414..92d6a7da26821d3f43b0bbe2b0cc460094e4b1cc 100644 (file)
@@ -53,7 +53,7 @@ ch_realloc(
     ber_len_t  size
 )
 {
-       void    *new;
+       void    *new, *ctx;
 
        if ( block == NULL ) {
                return( ch_malloc( size ) );
@@ -63,6 +63,11 @@ ch_realloc(
                ch_free( block );
        }
 
+       ctx = sl_context( block );
+       if ( ctx ) {
+               return sl_realloc( block, size, ctx );
+       }
+
        if ( (new = (void *) ber_memrealloc_x( block, size, NULL )) == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, ERR, 
@@ -126,6 +131,13 @@ ch_strdup(
 void
 ch_free( void *ptr )
 {
-       ber_memfree_x( ptr, NULL );
+       void *ctx;
+
+       ctx = sl_context( ptr );
+       if (ctx) {
+               sl_free( ptr, ctx );
+       } else {
+               ber_memfree_x( ptr, NULL );
+       }
 }