]> git.sur5r.net Git - openldap/commitdiff
more cleanup
authorPierangelo Masarati <ando@openldap.org>
Fri, 14 Nov 2003 20:00:20 +0000 (20:00 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 14 Nov 2003 20:00:20 +0000 (20:00 +0000)
libraries/librewrite/info.c
libraries/librewrite/ldapmap.c
libraries/librewrite/map.c
libraries/librewrite/rewrite-int.h
libraries/librewrite/rewrite-map.h
libraries/librewrite/subst.c
libraries/librewrite/var.c

index aeb43d6ee6993eb050919aed0448a88264ad7774..723cdbc1ecb90f8cf02a4c8bc0da9509f4fc0ff3 100644 (file)
@@ -117,6 +117,11 @@ rewrite_info_delete(
        }
        info->li_context = NULL;
 
+       if ( info->li_maps ) {
+               avl_free( info->li_maps, rewrite_builtin_map_free );
+       }
+       info->li_context = NULL;
+
        rewrite_session_destroy( info );
 
 #ifdef USE_REWRITE_LDAP_PVT_THREADS
@@ -172,7 +177,7 @@ rewrite_session(
 )
 {
        struct rewrite_context *context;
-       struct rewrite_op op = { 0, 0, NULL, NULL, NULL, NULL };
+       struct rewrite_op op = { 0, 0, NULL, NULL, NULL };
        int rc;
        
        assert( info != NULL );
@@ -218,21 +223,24 @@ rewrite_session(
                        break;
                }
        }
-       
+
+#if 0 /* FIXME: not used anywhere! (debug? then, why strdup?) */
        op.lo_string = strdup( string );
        if ( op.lo_string == NULL ) {
                rc = REWRITE_REGEXEC_ERR;
                goto rc_return;
        }
+#endif
        
        /*
         * Applies rewrite context
         */
-       rc = rewrite_context_apply(info, &op, context, string, result );
+       rc = rewrite_context_apply( info, &op, context, string, result );
        assert( op.lo_depth == 0 );
 
-       /* ?!? */
+#if 0 /* FIXME: not used anywhere! (debug? then, why strdup?) */       
        free( op.lo_string );
+#endif
        
        switch ( rc ) {
        /*
index 6f83ff7aa35d91844ba3907a4bb512b526a6a934..07e04bccf2d831e99340f9b2e11bab2d3ca54851 100644 (file)
@@ -331,3 +331,21 @@ rc_return:;
        return rc;
 }
 
+int
+map_ldap_destroy(
+               struct rewrite_builtin_map **pmap
+)
+{
+       struct ldap_map_data *data;
+
+       assert( pmap );
+       assert( *pmap );
+       
+       data = ( struct ldap_map_data * )(*pmap)->lb_private;
+
+       free( data );
+       *pmap = NULL;
+
+       return 0;
+}
+               
index c7acbc31eb1224a1d7092a5da2a9640520018912..cf563f079c6542e5b17f0cdd47b66289f195eb9f 100644 (file)
@@ -436,6 +436,28 @@ rewrite_map_apply(
        return rc;
 }
 
+void
+rewrite_builtin_map_free(
+               void *tmp
+)
+{
+       struct rewrite_builtin_map *map = ( struct rewrite_builtin_map * )tmp;
+
+       assert( map );
+
+       switch ( map->lb_type ) {
+       case REWRITE_BUILTIN_MAP_LDAP:
+               map_ldap_destroy( &map );
+               break;
+
+       default:
+               assert(0);
+               break;
+       }
+
+       free( map );
+}
+
 int
 rewrite_map_destroy(
                struct rewrite_map **pmap
index c30e617b2fc45ce7bdb7242279fcaef93f32fb1d..85358b72fc6fde99f50f8a6d747448b1d3519e6e 100644 (file)
@@ -262,7 +262,9 @@ struct rewrite_var {
 struct rewrite_op {
        int                             lo_num_passes;
        int                             lo_depth;
+#if 0 /* FIXME: not used anywhere! (debug? then, why strdup?) */
        char                           *lo_string;
+#endif
        char                           *lo_result;
        Avlnode                        *lo_vars;
        const void                     *lo_cookie;
@@ -369,6 +371,10 @@ rewrite_xmap_destroy(
                struct rewrite_map **map
 );
 
+LDAP_REWRITE_F (void)
+rewrite_builtin_map_free(
+               void *map
+);
 /*
  * Submatch substitution
  */
index 918dc4b063e08019988bcc64118b9bb1d6315483..13283e4bed5ed555ea0a889c3293a978bd53474d 100644 (file)
@@ -53,4 +53,7 @@ map_ldap_apply( struct rewrite_builtin_map *map,
                struct berval *val
 );
 
+LDAP_REWRITE_F (int)
+map_ldap_destroy( struct rewrite_builtin_map **map );
+
 #endif /* MAP_H */
index 6aafac51180535106b44d7ee999b373d75b9ee27..531b09900b6dbe05af95711cffcf8c867cc00d3f 100644 (file)
@@ -180,7 +180,6 @@ rewrite_subst_compile(
                free( submatch );
                return NULL;
        }
-
        subs = tmps;
        l = p - begin;
        if ( l > 0 ) {
index e701655a86241c0871fda40b7ad7f7a4bdf01f0e..aa39261ce5d48af243109451bdfb5ec8be5e9a24 100644 (file)
@@ -110,7 +110,7 @@ rewrite_var_insert(
                return NULL;
        }
        memset( var, 0, sizeof( struct rewrite_var ) );
-       var->lv_name = ( char * )strdup( name );
+       var->lv_name = strdup( name );
        if ( var->lv_name == NULL ) {
                rc = -1;
                goto cleanup;
@@ -190,6 +190,7 @@ rewrite_var_free(
 
        free( var->lv_name );
        free( var->lv_value.bv_val );
+       free( var );
 }
 
 /*