From fbc54d47d3d091d7d6af78f5068dc7e699d5ac5b Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 31 Dec 2001 06:01:59 +0000 Subject: [PATCH] Added ber_free_buf() --- include/lber.h | 3 +++ libraries/liblber/io.c | 36 +++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/include/lber.h b/include/lber.h index 7154544f80..90e0dfb351 100644 --- a/include/lber.h +++ b/include/lber.h @@ -406,6 +406,9 @@ ber_free LDAP_P(( BerElement *ber, int freebuf )); +LBER_F( void ) +ber_free_buf LDAP_P(( BerElement *ber )); + LBER_F( int ) ber_flush LDAP_P(( Sockbuf *sb, diff --git a/libraries/liblber/io.c b/libraries/liblber/io.c index b54f828cdc..d5de616da5 100644 --- a/libraries/liblber/io.c +++ b/libraries/liblber/io.c @@ -181,31 +181,37 @@ ber_realloc( BerElement *ber, ber_len_t len ) } void -ber_free( BerElement *ber, int freebuf ) +ber_free_buf( BerElement *ber ) { -#ifdef LDAP_MEMORY_DEBUG - assert( ber != NULL ); -#endif - - if( ber == NULL ) { - return; - } + Seqorset *s, *next; assert( LBER_VALID( ber ) ); - if ( freebuf ) { - Seqorset *s, *next; - LBER_FREE( ber->ber_buf ); + if ( ber->ber_buf) LBER_FREE( ber->ber_buf ); - for( s = ber->ber_sos ; s != NULL ; s = next ) { - next = s->sos_next; - LBER_FREE( s ); - } + for( s = ber->ber_sos ; s != NULL ; s = next ) { + next = s->sos_next; + LBER_FREE( s ); } ber->ber_buf = NULL; ber->ber_sos = NULL; ber->ber_valid = LBER_UNINITIALIZED; +} + +void +ber_free( BerElement *ber, int freebuf ) +{ +#ifdef LDAP_MEMORY_DEBUG + assert( ber != NULL ); +#endif + + if( ber == NULL ) { + return; + } + + if( freebuf ) + ber_free_buf( ber ); LBER_FREE( (char *) ber ); } -- 2.39.5