Harmonise slapi_ch_free() with Sun ONE API

This commit is contained in:
Luke Howard 2003-01-20 23:29:30 +00:00
parent 15276f6194
commit 45a66e2ed4
3 changed files with 33 additions and 35 deletions

View file

@ -86,7 +86,7 @@ internal_search_entry(
SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp ); SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp );
slapi_pblock_set( (Slapi_PBlock *)op->o_pb, slapi_pblock_set( (Slapi_PBlock *)op->o_pb,
SLAPI_NENTRIES, (void *)i ); SLAPI_NENTRIES, (void *)i );
slapi_ch_free( ent2str ); slapi_ch_free( (void **)&ent2str );
return LDAP_SUCCESS; return LDAP_SUCCESS;
} }
@ -154,15 +154,15 @@ fakeConnection(
pConn->c_pending_ops.stqh_first = pConn->c_pending_ops.stqh_first =
(Operation *) slapi_ch_calloc( 1, sizeof(Operation) ); (Operation *) slapi_ch_calloc( 1, sizeof(Operation) );
if ( pConn->c_pending_ops.stqh_first == NULL ) { if ( pConn->c_pending_ops.stqh_first == NULL ) {
slapi_ch_free( pConn ); slapi_ch_free( (void **)&pConn );
return (Connection *)NULL; return (Connection *)NULL;
} }
pConn->c_pending_ops.stqh_first->o_pb = pConn->c_pending_ops.stqh_first->o_pb =
(Slapi_PBlock *) slapi_pblock_new(); (Slapi_PBlock *) slapi_pblock_new();
if ( pConn->c_pending_ops.stqh_first->o_pb == NULL ) { if ( pConn->c_pending_ops.stqh_first->o_pb == NULL ) {
slapi_ch_free( pConn->c_pending_ops.stqh_first ); slapi_ch_free( (void **)&pConn->c_pending_ops.stqh_first );
slapi_ch_free( pConn ); slapi_ch_free( (void **)&pConn );
return (Connection *)NULL; return (Connection *)NULL;
} }
@ -447,8 +447,8 @@ LDAPModToEntry(
cleanup: cleanup:
if ( dn.bv_val ) slapi_ch_free( dn.bv_val ); if ( dn.bv_val ) slapi_ch_free( (void **)&dn.bv_val );
if ( op ) slapi_ch_free( op ); if ( op ) slapi_ch_free( (void **)&op );
if ( modlist != NULL ) slap_mods_free( modlist ); if ( modlist != NULL ) slap_mods_free( modlist );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
if ( pEntry != NULL ) { if ( pEntry != NULL ) {
@ -552,14 +552,14 @@ cleanup:
if (pPB != NULL) if (pPB != NULL)
slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc ); slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
if (dn.bv_val) slapi_ch_free(dn.bv_val); if (dn.bv_val) slapi_ch_free( (void **)&dn.bv_val );
if (pdn.bv_val) slapi_ch_free(pdn.bv_val); if (pdn.bv_val) slapi_ch_free( (void **)&pdn.bv_val );
if (ndn.bv_val) slapi_ch_free(ndn.bv_val); if (ndn.bv_val) slapi_ch_free( (void **)&ndn.bv_val );
if ( pConn != NULL ) { 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->o_dn.bv_val ) slapi_ch_free( op->o_dn.bv_val ); if ( op->o_dn.bv_val ) slapi_ch_free( (void **)&op->o_dn.bv_val );
if ( op ) slapi_ch_free( op ); if ( op ) slapi_ch_free( (void **)&op );
pSavePB = pPB; pSavePB = pPB;
free( pConn ); free( pConn );
} }
@ -640,10 +640,10 @@ cleanup:
} }
if ( pConn != NULL ) { 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 ) {
if ( op->o_ndn.bv_val ) { 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); free(op);
} }
@ -854,10 +854,10 @@ cleanup:
if ( nnewrdn.bv_val ) ch_free( newrdn.bv_val ); if ( nnewrdn.bv_val ) ch_free( newrdn.bv_val );
if ( pConn != NULL ) { 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 ) {
if ( op->o_dn.bv_val ) slapi_ch_free( op->o_dn.bv_val ); if ( op->o_dn.bv_val ) slapi_ch_free( (void **)&op->o_dn.bv_val );
slapi_ch_free( op ); slapi_ch_free( (void **)&op );
} }
pSavePB = pPB; pSavePB = pPB;
free( pConn ); free( pConn );
@ -1066,10 +1066,10 @@ cleanup:
if ( modlist != NULL ) slap_mods_free( modlist ); if ( modlist != NULL ) slap_mods_free( modlist );
if ( pConn != NULL ) { 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 ) {
if ( op->o_dn.bv_val ) slapi_ch_free( op->o_dn.bv_val ); if ( op->o_dn.bv_val ) slapi_ch_free( (void **)&op->o_dn.bv_val );
slapi_ch_free( op ); slapi_ch_free( (void **)&op );
} }
pSavePB = pPB; pSavePB = pPB;
free( pConn ); free( pConn );
@ -1244,9 +1244,9 @@ cleanup:
if ( an != NULL ) free( an ); if ( an != NULL ) free( an );
if ( c != NULL ) { 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 ) {
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 ); free( op );
} }
pSavePB = ptr; pSavePB = ptr;

View file

@ -87,7 +87,7 @@ slapi_str2entry(
pTmpS = slapi_ch_strdup( s ); pTmpS = slapi_ch_strdup( s );
if ( pTmpS != NULL ) { if ( pTmpS != NULL ) {
e = str2entry( pTmpS ); e = str2entry( pTmpS );
slapi_ch_free( pTmpS ); slapi_ch_free( (void **)&pTmpS );
} }
return e; return e;
@ -154,12 +154,12 @@ slapi_entry_dup( Slapi_Entry *e )
tmpEnt = (Slapi_Entry *)str2entry( tmp ); tmpEnt = (Slapi_Entry *)str2entry( tmp );
if ( tmpEnt == NULL ) { if ( tmpEnt == NULL ) {
slapi_ch_free( tmp ); slapi_ch_free( (void **)&tmp );
return (Slapi_Entry *)NULL; return (Slapi_Entry *)NULL;
} }
if (tmp != NULL) { if (tmp != NULL) {
slapi_ch_free( tmp ); slapi_ch_free( (void **)&tmp );
} }
return tmpEnt; return tmpEnt;
@ -397,13 +397,11 @@ slapi_ch_malloc( unsigned long size )
} }
void void
slapi_ch_free( void *ptr ) slapi_ch_free( void **ptr )
{ {
#if defined(LDAP_SLAPI) #if defined(LDAP_SLAPI)
#if 0 ch_free( *ptr );
if ( ptr != NULL ) /* not required ... */ *ptr = NULL;
#endif /* 0 */
ch_free( ptr );
#endif /* defined(LDAP_SLAPI) */ #endif /* defined(LDAP_SLAPI) */
} }
@ -496,7 +494,7 @@ slapi_control_present(
if ( val ) { if ( val ) {
*val = pTmpBval; *val = pTmpBval;
} else { } else {
slapi_ch_free( pTmpBval ); slapi_ch_free( (void **)&pTmpBval );
rc = 0; rc = 0;
} }
} }
@ -963,7 +961,7 @@ slapi_get_hostname( void )
} else if ( sysinfo( SI_HOSTNAME, hn, MAX_HOSTNAME ) < 0 ) { } else if ( sysinfo( SI_HOSTNAME, hn, MAX_HOSTNAME ) < 0 ) {
slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SYSINFO", slapi_log_error( SLAPI_LOG_FATAL, "SLAPI_SYSINFO",
"can't get hostname\n" ); "can't get hostname\n" );
slapi_ch_free( hn ); slapi_ch_free( (void **)&hn );
hn = NULL; hn = NULL;
} }
#else /* !_SPARC */ #else /* !_SPARC */
@ -986,7 +984,7 @@ slapi_get_hostname( void )
slapi_log_error( SLAPI_LOG_FATAL, slapi_log_error( SLAPI_LOG_FATAL,
"SLAPI_SYSINFO", "SLAPI_SYSINFO",
"can't get hostname\n" ); "can't get hostname\n" );
slapi_ch_free( static_hn ); slapi_ch_free( (void **)&static_hn );
static_hn = NULL; static_hn = NULL;
ldap_pvt_thread_mutex_unlock( &slapi_hn_mutex ); 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_entry_free( entries[k] );
} }
slapi_ch_free( entries ); slapi_ch_free( (void **)&entries );
#endif /* defined(LDAP_SLAPI) */ #endif /* defined(LDAP_SLAPI) */
} }

View file

@ -55,7 +55,7 @@ Slapi_Entry *slapi_entry_alloc();
void slapi_entry_free( Slapi_Entry *e ); void slapi_entry_free( Slapi_Entry *e );
int slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals ); int slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals );
char *slapi_ch_malloc( unsigned long size ); 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_calloc( unsigned long nelem, unsigned long size );
char *slapi_ch_realloc( char *block, unsigned long size ); char *slapi_ch_realloc( char *block, unsigned long size );
char *slapi_ch_strdup( char *s ); char *slapi_ch_strdup( char *s );