Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 13264 invoked by uid 500); 13 Jun 2001 00:16:53 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 13252 invoked by uid 1103); 13 Jun 2001 00:16:51 -0000 Date: 13 Jun 2001 00:16:51 -0000 Message-ID: <20010613001651.13251.qmail@apache.org> From: dreid@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/memory/unix apr_sms.c dreid 01/06/12 17:16:51 Modified: memory/unix apr_sms.c Log: Some small tidy ups for the sms code. Passing in the cleanup list rather than the sms makes it more obvious what we're doing. Revision Changes Path 1.20 +11 -15 apr/memory/unix/apr_sms.c Index: apr_sms.c =================================================================== RCS file: /home/cvs/apr/memory/unix/apr_sms.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- apr_sms.c 2001/06/10 14:50:10 1.19 +++ apr_sms.c 2001/06/13 00:16:50 1.20 @@ -113,7 +113,6 @@ } return sms->calloc_fn(sms, size); - } APR_DECLARE(void *) apr_sms_realloc(apr_sms_t *sms, void *mem, @@ -203,11 +202,11 @@ /* XXX - This should eventually be removed */ apr_pool_create(&sms->pool, pms ? pms->pool : NULL); - + /* Create the lock we'll use to protect cleanups and child lists */ apr_lock_create(&sms->sms_lock, APR_MUTEX, APR_LOCKALL, NULL, sms->pool); - + return APR_SUCCESS; } @@ -273,14 +272,11 @@ * * Call all the cleanup routines registered with a memory system. */ -static void apr_sms_do_cleanups(apr_sms_t *sms) +static void apr_sms_do_cleanups(struct apr_sms_cleanup *c) { - struct apr_sms_cleanup *cleanup; - - cleanup = sms->cleanups; - while (cleanup) { - cleanup->cleanup_fn(cleanup->data); - cleanup = cleanup->next; + while (c) { + c->cleanup_fn(c->data); + c = c->next; } } @@ -299,7 +295,7 @@ sms = sms->child; while (sms) { apr_sms_do_child_cleanups(sms); - apr_sms_do_cleanups(sms); + apr_sms_do_cleanups(sms->cleanups); if (sms->pre_destroy_fn != NULL) sms->pre_destroy_fn(sms); @@ -324,7 +320,7 @@ apr_sms_do_child_cleanups(sms); /* Run all cleanups, the memory will be freed by the reset */ - apr_sms_do_cleanups(sms); + apr_sms_do_cleanups(sms->cleanups); sms->cleanups = NULL; /* We don't have any child memory systems after the reset */ @@ -364,7 +360,7 @@ apr_sms_do_child_cleanups(sms); /* Run all cleanups, the memory will be freed by the destroy */ - apr_sms_do_cleanups(sms); + apr_sms_do_cleanups(sms->cleanups); } else { if (sms->accounting != sms) { @@ -403,7 +399,7 @@ * Run all cleanups, the memory will be freed by the destroying * of the accounting memory system. */ - apr_sms_do_cleanups(sms); + apr_sms_do_cleanups(sms->cleanups); /* Destroy the accounting memory system */ apr_sms_destroy(sms->accounting); @@ -461,7 +457,7 @@ /* XXX - This should eventually be removed */ apr_pool_destroy(sms->pool); - + /* 1 - If we have a self destruct, use it */ if (sms->destroy_fn) return sms->destroy_fn(sms);