apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r761339 - /apr/apr/trunk/memory/unix/apr_pools.c
Date Thu, 02 Apr 2009 16:31:54 GMT
Author: mturk
Date: Thu Apr  2 16:31:54 2009
New Revision: 761339

URL: http://svn.apache.org/viewvc?rev=761339&view=rev
Log:
I stil think this implementation should go away...
Anyhow, no need to store the pointer to already linked list just to be able to
call the free on that pointer

Modified:
    apr/apr/trunk/memory/unix/apr_pools.c

Modified: apr/apr/trunk/memory/unix/apr_pools.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/memory/unix/apr_pools.c?rev=761339&r1=761338&r2=761339&view=diff
==============================================================================
--- apr/apr/trunk/memory/unix/apr_pools.c (original)
+++ apr/apr/trunk/memory/unix/apr_pools.c Thu Apr  2 16:31:54 2009
@@ -540,6 +540,7 @@
 
 static void run_cleanups(cleanup_t **c);
 static void run_child_cleanups(cleanup_t **c);
+static void free_cleanups(cleanup_t **c);
 static void free_proc_chain(struct process_chain *procs);
 
 #if APR_POOL_DEBUG
@@ -724,6 +725,7 @@
     /* Run pre destroy cleanups */
     run_cleanups(&pool->pre_cleanups);
     pool->pre_cleanups = NULL;
+    free_cleanups(&pool->free_pre_cleanups);
     pool->free_pre_cleanups = NULL;
 
     /* Destroy the subpools.  The subpools will detach themselves from
@@ -735,6 +737,7 @@
     /* Run cleanups */
     run_cleanups(&pool->cleanups);
     pool->cleanups = NULL;
+    free_cleanups(&pool->free_cleanups);
     pool->free_cleanups = NULL;
 
     /* Free subprocesses */
@@ -752,6 +755,7 @@
     /* Run pre destroy cleanups */
     run_cleanups(&pool->pre_cleanups);
     pool->pre_cleanups = NULL;
+    free_cleanups(&pool->free_pre_cleanups);
     pool->free_pre_cleanups = NULL;
 
     /* Destroy the subpools.  The subpools will detach themselve from
@@ -762,6 +766,7 @@
 
     /* Run cleanups */
     run_cleanups(&pool->cleanups);
+    free_cleanups(&pool->free_cleanups);
 
     /* Free subprocesses */
     free_proc_chain(pool->subprocesses);
@@ -786,6 +791,7 @@
 
     block_list_destroy_all(pool->blocks);
     run_cleanups(&pool->final_cleanups);
+    free_cleanups(&pool->final_cleanups);
     block_list_destroy(&pool->final_block);
     free(pool);
 }
@@ -1849,7 +1855,7 @@
             c = p->free_cleanups;
             p->free_cleanups = c->next;
         } else {
-            c = apr_palloc(p, sizeof(cleanup_t));
+            c = malloc(sizeof(cleanup_t));
         }
         c->data = data;
         c->plain_cleanup_fn = plain_cleanup_fn;
@@ -1874,7 +1880,7 @@
             c = p->free_pre_cleanups;
             p->free_pre_cleanups = c->next;
         } else {
-            c = apr_palloc(p, sizeof(cleanup_t));
+            c = malloc(sizeof(cleanup_t));
         }
         c->data = data;
         c->plain_cleanup_fn = plain_cleanup_fn;
@@ -1984,6 +1990,18 @@
     while (c) {
         *cref = c->next;
         (*c->plain_cleanup_fn)((void *)c->data);
+        free(c);
+        c = *cref;
+    }
+}
+
+static void free_cleanups(cleanup_t **cref)
+{
+    cleanup_t *c = *cref;
+
+    while (c) {
+        *cref = c->next;
+        free(c);
         c = *cref;
     }
 }
@@ -1995,6 +2013,7 @@
     while (c) {
         *cref = c->next;
         (*c->child_cleanup_fn)((void *)c->data);
+        free(c);
         c = *cref;
     }
 }



Mime
View raw message