From: Luke Howard Date: Mon, 20 Jan 2003 23:29:30 +0000 (+0000) Subject: Harmonise slapi_ch_free() with Sun ONE API X-Git-Tag: NO_SLAP_OP_BLOCKS~579 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=45a66e2ed45dea076c2031a9cc8ed1e11e3902d5;p=openldap Harmonise slapi_ch_free() with Sun ONE API --- diff --git a/servers/slapd/slapi/slapi_ops.c b/servers/slapd/slapi/slapi_ops.c index b85b91b39f..24b2d3bb30 100644 --- a/servers/slapd/slapi/slapi_ops.c +++ b/servers/slapd/slapi/slapi_ops.c @@ -86,7 +86,7 @@ internal_search_entry( SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp ); slapi_pblock_set( (Slapi_PBlock *)op->o_pb, SLAPI_NENTRIES, (void *)i ); - slapi_ch_free( ent2str ); + slapi_ch_free( (void **)&ent2str ); return LDAP_SUCCESS; } @@ -154,15 +154,15 @@ fakeConnection( pConn->c_pending_ops.stqh_first = (Operation *) slapi_ch_calloc( 1, sizeof(Operation) ); if ( pConn->c_pending_ops.stqh_first == NULL ) { - slapi_ch_free( pConn ); + slapi_ch_free( (void **)&pConn ); return (Connection *)NULL; } pConn->c_pending_ops.stqh_first->o_pb = (Slapi_PBlock *) slapi_pblock_new(); if ( pConn->c_pending_ops.stqh_first->o_pb == NULL ) { - slapi_ch_free( pConn->c_pending_ops.stqh_first ); - slapi_ch_free( pConn ); + slapi_ch_free( (void **)&pConn->c_pending_ops.stqh_first ); + slapi_ch_free( (void **)&pConn ); return (Connection *)NULL; } @@ -447,8 +447,8 @@ LDAPModToEntry( cleanup: - if ( dn.bv_val ) slapi_ch_free( dn.bv_val ); - if ( op ) slapi_ch_free( op ); + if ( dn.bv_val ) slapi_ch_free( (void **)&dn.bv_val ); + if ( op ) slapi_ch_free( (void **)&op ); if ( modlist != NULL ) slap_mods_free( modlist ); if ( rc != LDAP_SUCCESS ) { if ( pEntry != NULL ) { @@ -552,14 +552,14 @@ cleanup: if (pPB != NULL) slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc ); - if (dn.bv_val) slapi_ch_free(dn.bv_val); - if (pdn.bv_val) slapi_ch_free(pdn.bv_val); - if (ndn.bv_val) slapi_ch_free(ndn.bv_val); + if (dn.bv_val) slapi_ch_free( (void **)&dn.bv_val ); + if (pdn.bv_val) slapi_ch_free( (void **)&pdn.bv_val ); + if (ndn.bv_val) slapi_ch_free( (void **)&ndn.bv_val ); if ( pConn != NULL ) { - if ( pConn->c_dn.bv_val ) slapi_ch_free( pConn->c_dn.bv_val ); - if ( op->o_dn.bv_val ) slapi_ch_free( op->o_dn.bv_val ); - if ( op ) slapi_ch_free( op ); + if ( pConn->c_dn.bv_val ) slapi_ch_free( (void **)&pConn->c_dn.bv_val ); + if ( op->o_dn.bv_val ) slapi_ch_free( (void **)&op->o_dn.bv_val ); + if ( op ) slapi_ch_free( (void **)&op ); pSavePB = pPB; free( pConn ); } @@ -640,10 +640,10 @@ cleanup: } if ( pConn != NULL ) { - if ( pConn->c_dn.bv_val ) slapi_ch_free( pConn->c_dn.bv_val ); + if ( pConn->c_dn.bv_val ) slapi_ch_free( (void **)&pConn->c_dn.bv_val ); if ( op ) { if ( op->o_ndn.bv_val ) { - slapi_ch_free( op->o_ndn.bv_val ); + slapi_ch_free( (void **)&op->o_ndn.bv_val ); } free(op); } @@ -854,10 +854,10 @@ cleanup: if ( nnewrdn.bv_val ) ch_free( newrdn.bv_val ); if ( pConn != NULL ) { - if ( pConn->c_dn.bv_val ) slapi_ch_free( pConn->c_dn.bv_val ); + if ( pConn->c_dn.bv_val ) slapi_ch_free( (void **)&pConn->c_dn.bv_val ); if ( op ) { - if ( op->o_dn.bv_val ) slapi_ch_free( op->o_dn.bv_val ); - slapi_ch_free( op ); + if ( op->o_dn.bv_val ) slapi_ch_free( (void **)&op->o_dn.bv_val ); + slapi_ch_free( (void **)&op ); } pSavePB = pPB; free( pConn ); @@ -1066,10 +1066,10 @@ cleanup: if ( modlist != NULL ) slap_mods_free( modlist ); if ( pConn != NULL ) { - if ( pConn->c_dn.bv_val ) slapi_ch_free( pConn->c_dn.bv_val ); + if ( pConn->c_dn.bv_val ) slapi_ch_free( (void **)&pConn->c_dn.bv_val ); if ( op ) { - if ( op->o_dn.bv_val ) slapi_ch_free( op->o_dn.bv_val ); - slapi_ch_free( op ); + if ( op->o_dn.bv_val ) slapi_ch_free( (void **)&op->o_dn.bv_val ); + slapi_ch_free( (void **)&op ); } pSavePB = pPB; free( pConn ); @@ -1244,9 +1244,9 @@ cleanup: if ( an != NULL ) free( an ); if ( c != NULL ) { - if ( c->c_dn.bv_val ) slapi_ch_free( c->c_dn.bv_val ); + if ( c->c_dn.bv_val ) slapi_ch_free( (void **)&c->c_dn.bv_val ); if ( op ) { - if ( op->o_ndn.bv_val ) slapi_ch_free( op->o_ndn.bv_val ); + if ( op->o_ndn.bv_val ) slapi_ch_free( (void **)&op->o_ndn.bv_val ); free( op ); } pSavePB = ptr; diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index db1907b956..e9b7521522 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -87,7 +87,7 @@ slapi_str2entry( pTmpS = slapi_ch_strdup( s ); if ( pTmpS != NULL ) { e = str2entry( pTmpS ); - slapi_ch_free( pTmpS ); + slapi_ch_free( (void **)&pTmpS ); } return e; @@ -154,12 +154,12 @@ slapi_entry_dup( Slapi_Entry *e ) tmpEnt = (Slapi_Entry *)str2entry( tmp ); if ( tmpEnt == NULL ) { - slapi_ch_free( tmp ); + slapi_ch_free( (void **)&tmp ); return (Slapi_Entry *)NULL; } if (tmp != NULL) { - slapi_ch_free( tmp ); + slapi_ch_free( (void **)&tmp ); } return tmpEnt; @@ -397,13 +397,11 @@ slapi_ch_malloc( unsigned long size ) } void -slapi_ch_free( void *ptr ) +slapi_ch_free( void **ptr ) { #if defined(LDAP_SLAPI) -#if 0 - if ( ptr != NULL ) /* not required ... */ -#endif /* 0 */ - ch_free( ptr ); + ch_free( *ptr ); + *ptr = NULL; #endif /* defined(LDAP_SLAPI) */ } @@ -496,7 +494,7 @@ slapi_control_present( if ( val ) { *val = pTmpBval; } else { - slapi_ch_free( pTmpBval ); + slapi_ch_free( (void **)&pTmpBval ); rc = 0; } } @@ -963,7 +961,7 @@ slapi_get_hostname( void ) } else if ( sysinfo( SI_HOSTNAME, hn, MAX_HOSTNAME ) < 0 ) { slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SYSINFO", "can't get hostname\n" ); - slapi_ch_free( hn ); + slapi_ch_free( (void **)&hn ); hn = NULL; } #else /* !_SPARC */ @@ -986,7 +984,7 @@ slapi_get_hostname( void ) slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SYSINFO", "can't get hostname\n" ); - slapi_ch_free( static_hn ); + slapi_ch_free( (void **)&static_hn ); static_hn = NULL; ldap_pvt_thread_mutex_unlock( &slapi_hn_mutex ); @@ -1130,7 +1128,7 @@ slapi_free_search_results_internal( Slapi_PBlock *pb ) slapi_entry_free( entries[k] ); } - slapi_ch_free( entries ); + slapi_ch_free( (void **)&entries ); #endif /* defined(LDAP_SLAPI) */ } diff --git a/servers/slapd/slapi/slapi_utils.h b/servers/slapd/slapi/slapi_utils.h index 35efc525d2..e231539aec 100644 --- a/servers/slapd/slapi/slapi_utils.h +++ b/servers/slapd/slapi/slapi_utils.h @@ -55,7 +55,7 @@ Slapi_Entry *slapi_entry_alloc(); void slapi_entry_free( Slapi_Entry *e ); int slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals ); char *slapi_ch_malloc( unsigned long size ); -void slapi_ch_free( void *ptr ); +void slapi_ch_free( void **ptr ); char *slapi_ch_calloc( unsigned long nelem, unsigned long size ); char *slapi_ch_realloc( char *block, unsigned long size ); char *slapi_ch_strdup( char *s );