]> git.sur5r.net Git - openldap/commitdiff
Harmonise slapi_ch_free() with Sun ONE API
authorLuke Howard <lukeh@openldap.org>
Mon, 20 Jan 2003 23:29:30 +0000 (23:29 +0000)
committerLuke Howard <lukeh@openldap.org>
Mon, 20 Jan 2003 23:29:30 +0000 (23:29 +0000)
servers/slapd/slapi/slapi_ops.c
servers/slapd/slapi/slapi_utils.c
servers/slapd/slapi/slapi_utils.h

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