dreid 01/06/10 07:45:33
Modified: include apr_sms.h
memory/unix apr_sms.c apr_sms_std.c apr_sms_tracking.c
Log:
Renaming of sms to use shorter names, no functional change.
mem_sys => sms
parent_mem_sys => parent
child_mem_sys => child
ref_mem_sys => ref
accounting_mem_sys => accounting
sibling_mem_sys => sibling
Revision Changes Path
1.14 +66 -66 apr/include/apr_sms.h
Index: apr_sms.h
===================================================================
RCS file: /home/cvs/apr/include/apr_sms.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- apr_sms.h 2001/06/08 02:34:23 1.13
+++ apr_sms.h 2001/06/10 14:45:32 1.14
@@ -89,11 +89,11 @@
*/
struct apr_sms_t
{
- apr_sms_t *parent_mem_sys;
- apr_sms_t *child_mem_sys;
- apr_sms_t *sibling_mem_sys;
- apr_sms_t **ref_mem_sys;
- apr_sms_t *accounting_mem_sys;
+ apr_sms_t *parent;
+ apr_sms_t *child;
+ apr_sms_t *sibling;
+ apr_sms_t **ref;
+ apr_sms_t *accounting;
const char *identity; /* a string identifying the module */
apr_pool_t *pool;
@@ -101,16 +101,16 @@
struct apr_sms_cleanup *cleanups;
- void * (*malloc_fn) (apr_sms_t *mem_sys, apr_size_t size);
- void * (*calloc_fn) (apr_sms_t *mem_sys, apr_size_t size);
- void * (*realloc_fn) (apr_sms_t *mem_sys, void *memory,
+ void * (*malloc_fn) (apr_sms_t *sms, apr_size_t size);
+ void * (*calloc_fn) (apr_sms_t *sms, apr_size_t size);
+ void * (*realloc_fn) (apr_sms_t *sms, void *memory,
apr_size_t size);
- apr_status_t (*free_fn) (apr_sms_t *mem_sys, void *memory);
- apr_status_t (*reset_fn) (apr_sms_t *mem_sys);
- apr_status_t (*pre_destroy_fn) (apr_sms_t *mem_sys);
- apr_status_t (*destroy_fn) (apr_sms_t *mem_sys);
- apr_status_t (*lock_fn) (apr_sms_t *mem_sys);
- apr_status_t (*unlock_fn) (apr_sms_t *mem_sys);
+ apr_status_t (*free_fn) (apr_sms_t *sms, void *memory);
+ apr_status_t (*reset_fn) (apr_sms_t *sms);
+ apr_status_t (*pre_destroy_fn) (apr_sms_t *sms);
+ apr_status_t (*destroy_fn) (apr_sms_t *sms);
+ apr_status_t (*lock_fn) (apr_sms_t *sms);
+ apr_status_t (*unlock_fn) (apr_sms_t *sms);
};
/*
@@ -119,46 +119,46 @@
/**
* Allocate a block of memory using a certain memory system
- * @param mem_sys The memory system to use
+ * @param sms The memory system to use
* @param size The (minimal required) size of the block to be allocated
* @return pointer to a newly allocated block of memory, NULL if insufficient
* memory available
- * @deffunc void *apr_sms_malloc(apr_sms_t *mem_sys, apr_size_t size)
+ * @deffunc void *apr_sms_malloc(apr_sms_t *sms, apr_size_t size)
*/
-APR_DECLARE(void *) apr_sms_malloc(apr_sms_t *mem_sys, apr_size_t size);
+APR_DECLARE(void *) apr_sms_malloc(apr_sms_t *sms, apr_size_t size);
/**
* Allocate a block of zeroed memory using a certain memory system
- * @param mem_sys The memory system to use
+ * @param sms The memory system to use
* @param size The (minimal required) size of the block to be allocated
* @return pointer to a newly allocated block of memory, NULL if insufficient
* memory available
- * @deffunc void *apr_sms_calloc(apr_sms_t *mem_sys, apr_size_t size)
+ * @deffunc void *apr_sms_calloc(apr_sms_t *sms, apr_size_t size)
*/
-APR_DECLARE(void *) apr_sms_calloc(apr_sms_t *mem_sys, apr_size_t size);
+APR_DECLARE(void *) apr_sms_calloc(apr_sms_t *sms, apr_size_t size);
/**
* Change the size of a previously allocated block of memory
- * @param mem_sys The memory system to use (should be the same as the
+ * @param sms The memory system to use (should be the same as the
* one that returned the block)
* @param mem Pointer to the previously allocated block. If NULL, this
* function acts like apr_sms_malloc.
* @param size The (minimal required) size of the block to be allocated
* @return pointer to a newly allocated block of memory, NULL if insufficient
* memory available
- * @deffunc void *apr_sms_realloc(apr_sms_t *mem_sys, void *mem, apr_size_t
size)
+ * @deffunc void *apr_sms_realloc(apr_sms_t *sms, void *mem, apr_size_t size)
*/
-APR_DECLARE(void *) apr_sms_realloc(apr_sms_t *mem_sys, void *mem,
apr_size_t size);
+APR_DECLARE(void *) apr_sms_realloc(apr_sms_t *sms, void *mem, apr_size_t
size);
/**
* Free a block of memory
- * @param mem_sys The memory system to use (should be the same as the
+ * @param sms The memory system to use (should be the same as the
* one that returned the block)
* @param mem The block of memory to be freed
- * @deffunc void apr_sms_free(apr_sms_t *mem_sys,
+ * @deffunc void apr_sms_free(apr_sms_t *sms,
* void *mem)
*/
-APR_DECLARE(apr_status_t) apr_sms_free(apr_sms_t *mem_sys, void *mem);
+APR_DECLARE(apr_status_t) apr_sms_free(apr_sms_t *sms, void *mem);
/*
* memory system functions
@@ -170,27 +170,27 @@
* to serve as a memory system structure from your
* apr_xxx_sms_create. Only use this function when you are
* implementing a memory system.
- * @param mem_sys The memory system created
- * @param parent_mem_sys The parent memory system
+ * @param sms The memory system created
+ * @param parent_sms The parent memory system
* @deffunc apr_status_t apr_sms_init(apr_sms_t *sms,
- * apr_sms_t *parent_mem_sys)
+ * apr_sms_t *parent_sms)
*/
-APR_DECLARE(apr_status_t) apr_sms_init(apr_sms_t *mem_sys,
- apr_sms_t *parent_mem_sys);
+APR_DECLARE(apr_status_t) apr_sms_init(apr_sms_t *sms,
+ apr_sms_t *parent_sms);
/**
* Check if a memory system is obeying all rules.
* @caution Call this function as the last statement before returning a new
* memory system from your apr_xxx_sms_create.
- * @deffunc void apr_sms_validate(apr_sms_t *mem_sys)
+ * @deffunc void apr_sms_validate(apr_sms_t *sms)
*/
#ifdef APR_ASSERT_MEMORY
-APR_DECLARE(void) apr_sms_assert(apr_sms_t *mem_sys);
+APR_DECLARE(void) apr_sms_assert(apr_sms_t *sms);
#else
#ifdef apr_sms_assert
#undef apr_sms_assert
#endif
-#define apr_sms_assert(mem_sys)
+#define apr_sms_assert(sms)
#endif /* APR_ASSERT_MEMORY */
/**
@@ -199,33 +199,33 @@
* @warning This function will fail if there is no reset function available
* for the given memory system (i.e. the memory system is non-
* tracking).
- * @param mem_sys The memory system to be reset
- * @deffunc apr_status_t apr_sms_reset(apr_sms_t *mem_sys)
+ * @param sms The memory system to be reset
+ * @deffunc apr_status_t apr_sms_reset(apr_sms_t *sms)
*/
-APR_DECLARE(apr_status_t) apr_sms_reset(apr_sms_t *mem_sys);
+APR_DECLARE(apr_status_t) apr_sms_reset(apr_sms_t *sms);
/**
* Destroy a memory system, effectively freeing all of its memory, and
itself.
* This will also run all cleanup functions associated with the memory
system.
* @caution Be carefull when using this function with a non-tracking memory
* system
- * @param mem_sys The memory system to be destroyed
- * @deffunc apr_status_t apr_sms_destroy(apr_sms_t *mem_sys)
+ * @param sms The memory system to be destroyed
+ * @deffunc apr_status_t apr_sms_destroy(apr_sms_t *sms)
*/
-APR_DECLARE(apr_status_t) apr_sms_destroy(apr_sms_t *mem_sys);
+APR_DECLARE(apr_status_t) apr_sms_destroy(apr_sms_t *sms);
/**
* Perform thread-safe locking required whilst this memory system is modified
- * @param mem_sys The memory system to be locked for thread-safety
+ * @param sms The memory system to be locked for thread-safety
*/
-APR_DECLARE(apr_status_t) apr_sms_lock(apr_sms_t *mem_sys);
+APR_DECLARE(apr_status_t) apr_sms_lock(apr_sms_t *sms);
/**
* Release thread-safe locking required whilst this memory system was
* being modified
- * @param mem_sys The memory system to be released from thread-safety
+ * @param sms The memory system to be released from thread-safety
*/
-APR_DECLARE(apr_status_t) apr_sms_unlock(apr_sms_t *mem_sys);
+APR_DECLARE(apr_status_t) apr_sms_unlock(apr_sms_t *sms);
/**
* Determine if memory system a is an ancestor of memory system b
@@ -239,10 +239,10 @@
/**
* Get the memory_system identity
- * @param mem_sys The memory system to use
- * @deffunc const char * apr_sms_identity(apr_sms_t *mem_sys);
+ * @param sms The memory system to use
+ * @deffunc const char * apr_sms_identity(apr_sms_t *sms);
*/
-APR_DECLARE(const char *) apr_sms_identity(apr_sms_t *mem_sys);
+APR_DECLARE(const char *) apr_sms_identity(apr_sms_t *sms);
/*
* memory system cleanup management functions
@@ -250,75 +250,75 @@
/**
* Register a function to be called when a memory system is reset or
destroyed
- * @param mem_sys The memory system to register the cleanup function with
+ * @param sms The memory system to register the cleanup function with
* @param type The type of cleanup to register
* @param data The data to pass to the cleanup function
* @param cleanup_fn The function to call when the memory system is reset or
* destroyed
- * @deffunc void apr_sms_cleanup_register(apr_sms_t *mem_sys, apr_int32_t
type,
+ * @deffunc void apr_sms_cleanup_register(apr_sms_t *sms, apr_int32_t type,
* void *data, apr_status_t (*cleanup_fn)(void *));
*/
-APR_DECLARE(apr_status_t) apr_sms_cleanup_register(apr_sms_t *mem_sys,
apr_int32_t type,
+APR_DECLARE(apr_status_t) apr_sms_cleanup_register(apr_sms_t *sms,
apr_int32_t type,
void *data,
apr_status_t
(*cleanup_fn)(void *));
/**
* Unregister a previously registered cleanup function
- * @param mem_sys The memory system the cleanup function is registered
+ * @param sms The memory system the cleanup function is registered
* with
* @param type The type of the cleanup to unregister
* @param data The data associated with the cleanup function
* @param cleanup_fn The registered cleanup function
- * @deffunc void apr_sms_cleanup_unregister(apr_sms_t *mem_sys,
+ * @deffunc void apr_sms_cleanup_unregister(apr_sms_t *sms,
* void *data, apr_status_t (*cleanup_fn)(void *));
*/
-APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister(apr_sms_t *mem_sys,
apr_int32_t type,
+APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister(apr_sms_t *sms,
apr_int32_t type,
void *data,
apr_status_t
(*cleanup)(void *));
/**
* Unregister all previously registered cleanup functions of the specified
type
- * @param mem_sys The memory system the cleanup functions are registered with
+ * @param sms The memory system the cleanup functions are registered with
* @param type The type associated with the cleanup function. Pass 0 to
* unregister all cleanup functions.
- * @deffunc apr_status_t apr_sms_cleanup_unregister_type(apr_sms_t *mem_sys,
+ * @deffunc apr_status_t apr_sms_cleanup_unregister_type(apr_sms_t *sms,
* apr_int32_t type);
*/
-APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister_type(apr_sms_t *mem_sys,
+APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister_type(apr_sms_t *sms,
apr_int32_t type);
/**
* Run the specified cleanup function immediately and unregister it
- * @param mem_sys The memory system the cleanup function is registered
+ * @param sms The memory system the cleanup function is registered
* with
- * @param mem_sys The memory system the cleanup function is registered with
+ * @param sms The memory system the cleanup function is registered with
* @param type The type associated with the cleanup function. Pass 0 to
ignore type.
* @param data The data associated with the cleanup function
* @param cleanup The registered cleanup function
- * @deffunc apr_status_t apr_sms_cleanup_run(apr_sms_t *mem_sys,
+ * @deffunc apr_status_t apr_sms_cleanup_run(apr_sms_t *sms,
* apr_int32_t type, void *data, apr_status_t
(*cleanup)(void *));
*/
-APR_DECLARE(apr_status_t) apr_sms_cleanup_run(apr_sms_t *mem_sys,
+APR_DECLARE(apr_status_t) apr_sms_cleanup_run(apr_sms_t *sms,
apr_int32_t type, void *data,
apr_status_t (*cleanup)(void
*));
/**
* Run the specified type of cleanup functions immediately and unregister
them
- * @param mem_sys The memory system the cleanup functions are registered with
+ * @param sms The memory system the cleanup functions are registered with
* @param type The category of cleanup functions to run. Pass 0 to run all
* cleanup functions.
- * @deffunc apr_status_t apr_sms_cleanup_run_type(apr_sms_t *mem_sys,
+ * @deffunc apr_status_t apr_sms_cleanup_run_type(apr_sms_t *sms,
* apr_int32_t type);
*/
-APR_DECLARE(apr_status_t) apr_sms_cleanup_run_type(apr_sms_t *mem_sys,
+APR_DECLARE(apr_status_t) apr_sms_cleanup_run_type(apr_sms_t *sms,
apr_int32_t type);
/**
* Create a standard malloc/realloc/free memory system
- * @param mem_sys A pointer to the created apr_sms_t*
- * @deffunc apr_status_t apr_sms_std_create(apr_sms_t **mem_sys);
+ * @param sms A pointer to the created apr_sms_t*
+ * @deffunc apr_status_t apr_sms_std_create(apr_sms_t **sms);
*/
-APR_DECLARE(apr_status_t) apr_sms_std_create(apr_sms_t **mem_sys);
+APR_DECLARE(apr_status_t) apr_sms_std_create(apr_sms_t **sms);
#ifdef __cplusplus
}
1.18 +147 -147 apr/memory/unix/apr_sms.c
Index: apr_sms.c
===================================================================
RCS file: /home/cvs/apr/memory/unix/apr_sms.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- apr_sms.c 2001/06/10 14:37:38 1.17
+++ apr_sms.c 2001/06/10 14:45:32 1.18
@@ -88,53 +88,53 @@
* memory allocation functions
*/
-APR_DECLARE(void *) apr_sms_malloc(apr_sms_t *mem_sys,
+APR_DECLARE(void *) apr_sms_malloc(apr_sms_t *sms,
apr_size_t size)
{
if (size == 0)
return NULL;
- return mem_sys->malloc_fn(mem_sys, size);
+ return sms->malloc_fn(sms, size);
}
-APR_DECLARE(void *) apr_sms_calloc(apr_sms_t *mem_sys,
+APR_DECLARE(void *) apr_sms_calloc(apr_sms_t *sms,
apr_size_t size)
{
if (size == 0)
return NULL;
- if (!mem_sys->calloc_fn) {
+ if (!sms->calloc_fn) {
/* Assumption - if we don't have calloc we have
* malloc, might be bogus...
*/
- void *mem = mem_sys->malloc_fn(mem_sys, size);
+ void *mem = sms->malloc_fn(sms, size);
memset(mem, '\0', size);
return mem;
}
- return mem_sys->calloc_fn(mem_sys, size);
+ return sms->calloc_fn(sms, size);
}
-APR_DECLARE(void *) apr_sms_realloc(apr_sms_t *mem_sys, void *mem,
+APR_DECLARE(void *) apr_sms_realloc(apr_sms_t *sms, void *mem,
apr_size_t size)
{
if (!mem)
- return apr_sms_malloc(mem_sys, size);
+ return apr_sms_malloc(sms, size);
if (size == 0) {
- apr_sms_free(mem_sys, mem);
+ apr_sms_free(sms, mem);
return NULL;
}
- return mem_sys->realloc_fn(mem_sys, mem, size);
+ return sms->realloc_fn(sms, mem, size);
}
-APR_DECLARE(apr_status_t) apr_sms_free(apr_sms_t *mem_sys,
+APR_DECLARE(apr_status_t) apr_sms_free(apr_sms_t *sms,
void *mem)
{
- if (mem_sys->free_fn)
- return mem_sys->free_fn(mem_sys, mem);
+ if (sms->free_fn)
+ return sms->free_fn(sms, mem);
return APR_ENOTIMPL;
}
@@ -143,16 +143,16 @@
* memory system functions
*/
-static int apr_sms_is_tracking(apr_sms_t *mem_sys)
+static int apr_sms_is_tracking(apr_sms_t *sms)
{
/*
* The presense of a reset function gives us the clue that this is a
* tracking memory system.
*/
- return mem_sys->reset_fn != NULL;
+ return sms->reset_fn != NULL;
}
-APR_DECLARE(apr_status_t) apr_sms_init(apr_sms_t *mem_sys,
+APR_DECLARE(apr_status_t) apr_sms_init(apr_sms_t *sms,
apr_sms_t *pms)
{
/* XXX - I've assumed that memory passed in will be zeroed,
@@ -163,9 +163,9 @@
* an assumption to make as it sounds :)
*/
- mem_sys->parent_mem_sys = pms;
- mem_sys->accounting_mem_sys = mem_sys;
- mem_sys->child_mem_sys = NULL;
+ sms->parent = pms;
+ sms->accounting = sms;
+ sms->child = NULL;
/*
* Child memory systems are always linked to their parents. This works
@@ -192,34 +192,34 @@
*/
apr_lock_acquire(pms->sms_lock);
- if ((mem_sys->sibling_mem_sys = pms->child_mem_sys) != NULL)
- mem_sys->sibling_mem_sys->ref_mem_sys =
&mem_sys->sibling_mem_sys;
+ if ((sms->sibling = pms->child) != NULL)
+ sms->sibling->ref = &sms->sibling;
- mem_sys->ref_mem_sys = &pms->child_mem_sys;
- pms->child_mem_sys = mem_sys;
+ sms->ref = &pms->child;
+ pms->child = sms;
apr_lock_release(pms->sms_lock);
}
/* XXX - This should eventually be removed */
- apr_pool_create(&mem_sys->pool, pms ? pms->pool : NULL);
+ apr_pool_create(&sms->pool, pms ? pms->pool : NULL);
/* Create the lock we'll use to protect cleanups and child lists */
- apr_lock_create(&mem_sys->sms_lock, APR_MUTEX, APR_LOCKALL, NULL,
- mem_sys->pool);
+ apr_lock_create(&sms->sms_lock, APR_MUTEX, APR_LOCKALL, NULL,
+ sms->pool);
return APR_SUCCESS;
}
#ifdef APR_ASSERT_MEMORY
-APR_DECLARE(void) apr_sms_assert(apr_sms_t *mem_sys)
+APR_DECLARE(void) apr_sms_assert(apr_sms_t *sms)
{
apr_sms_t *parent;
/*
* A memory system without a malloc won't do us much good
*/
- assert(mem_sys->malloc_fn);
+ assert(sms->malloc_fn);
/*
* Check to see if this is either a non-tracking or
@@ -227,19 +227,19 @@
* or destroy function. And to avoid half implementations
* we require reset to be present when destroy is.
*/
- assert(mem_sys->free_fn || (mem_sys->destroy_fn && mem_sys->reset_fn));
+ assert(sms->free_fn || (sms->destroy_fn && sms->reset_fn));
- assert(!mem_sys->destroy_fn || mem_sys->reset_fn);
+ assert(!sms->destroy_fn || sms->reset_fn);
- assert(!mem_sys->reset_fn || mem_sys->destroy_fn);
+ assert(!sms->reset_fn || sms->destroy_fn);
/*
* Make sure all accounting memory dies with the memory system.
* To be more specific, make sure the accounting memort system
* is either the memory system itself or a direct child.
*/
- assert(mem_sys->accounting_mem_sys == mem_sys ||
- mem_sys->accounting_mem_sys->parent_mem_sys == mem_sys);
+ assert(sms->accounting == sms ||
+ sms->accounting->parent == sms);
/*
* A non-tracking memory system can be the child of
@@ -247,15 +247,15 @@
* tracking ancestors, but in that specific case we issue a
* warning.
*/
- if (!mem_sys->parent_mem_sys)
+ if (!sms->parent)
return;
- parent = mem_sys;
+ parent = sms;
while (parent) {
if (apr_sms_is_tracking(parent))
return; /* Tracking memory system found, return satisfied ;-) */
- parent = parent->parent_mem_sys;
+ parent = parent->parent;
}
/* issue a warning:
@@ -273,11 +273,11 @@
*
* Call all the cleanup routines registered with a memory system.
*/
-static void apr_sms_do_cleanups(apr_sms_t *mem_sys)
+static void apr_sms_do_cleanups(apr_sms_t *sms)
{
struct apr_sms_cleanup *cleanup;
- cleanup = mem_sys->cleanups;
+ cleanup = sms->cleanups;
while (cleanup) {
cleanup->cleanup_fn(cleanup->data);
cleanup = cleanup->next;
@@ -291,44 +291,44 @@
*
* This not only calls do_cleanups, but also calls the pre_destroy(!)
*/
-static void apr_sms_do_child_cleanups(apr_sms_t *mem_sys)
+static void apr_sms_do_child_cleanups(apr_sms_t *sms)
{
- if (!mem_sys)
+ if (!sms)
return;
- mem_sys = mem_sys->child_mem_sys;
- while (mem_sys) {
- apr_sms_do_child_cleanups(mem_sys);
- apr_sms_do_cleanups(mem_sys);
+ sms = sms->child;
+ while (sms) {
+ apr_sms_do_child_cleanups(sms);
+ apr_sms_do_cleanups(sms);
- if (mem_sys->pre_destroy_fn != NULL)
- mem_sys->pre_destroy_fn(mem_sys);
+ if (sms->pre_destroy_fn != NULL)
+ sms->pre_destroy_fn(sms);
- mem_sys = mem_sys->sibling_mem_sys;
+ sms = sms->sibling;
}
}
-APR_DECLARE(apr_status_t) apr_sms_reset(apr_sms_t *mem_sys)
+APR_DECLARE(apr_status_t) apr_sms_reset(apr_sms_t *sms)
{
apr_status_t rv;
- if (!mem_sys->reset_fn)
+ if (!sms->reset_fn)
return APR_ENOTIMPL;
- apr_lock_acquire(mem_sys->sms_lock);
+ apr_lock_acquire(sms->sms_lock);
/*
* Run the cleanups of all child memory systems _including_
* the accounting memory system.
*/
- apr_sms_do_child_cleanups(mem_sys);
+ apr_sms_do_child_cleanups(sms);
/* Run all cleanups, the memory will be freed by the reset */
- apr_sms_do_cleanups(mem_sys);
- mem_sys->cleanups = NULL;
+ apr_sms_do_cleanups(sms);
+ sms->cleanups = NULL;
/* We don't have any child memory systems after the reset */
- mem_sys->child_mem_sys = NULL;
+ sms->child = NULL;
/* Reset the accounting memory system to ourselves, any
* child memory system _including_ the accounting memory
@@ -336,152 +336,152 @@
* strikerXXX: Maybe this should be the responsibility of
* the reset function(?).
*/
- mem_sys->accounting_mem_sys = mem_sys;
+ sms->accounting = sms;
/* Let the memory system handle the actual reset */
- rv = mem_sys->reset_fn(mem_sys);
+ rv = sms->reset_fn(sms);
- apr_lock_release(mem_sys->sms_lock);
+ apr_lock_release(sms->sms_lock);
return rv;
}
-APR_DECLARE(apr_status_t) apr_sms_destroy(apr_sms_t *mem_sys)
+APR_DECLARE(apr_status_t) apr_sms_destroy(apr_sms_t *sms)
{
- apr_sms_t *child_mem_sys;
- apr_sms_t *sibling_mem_sys;
+ apr_sms_t *child;
+ apr_sms_t *sibling;
apr_sms_t *pms;
struct apr_sms_cleanup *cleanup;
struct apr_sms_cleanup *next_cleanup;
- apr_lock_acquire(mem_sys->sms_lock);
+ apr_lock_acquire(sms->sms_lock);
- if (apr_sms_is_tracking(mem_sys)) {
+ if (apr_sms_is_tracking(sms)) {
/*
* Run the cleanups of all child memory systems _including_
* the accounting memory system.
*/
- apr_sms_do_child_cleanups(mem_sys);
+ apr_sms_do_child_cleanups(sms);
/* Run all cleanups, the memory will be freed by the destroy */
- apr_sms_do_cleanups(mem_sys);
+ apr_sms_do_cleanups(sms);
}
else {
- if (mem_sys->accounting_mem_sys != mem_sys) {
- child_mem_sys = mem_sys->accounting_mem_sys;
+ if (sms->accounting != sms) {
+ child = sms->accounting;
/*
* Remove the accounting memory system from the memory systems
* child list (we will explicitly destroy it later in this
block).
*/
- if (child_mem_sys->sibling_mem_sys != NULL)
- child_mem_sys->sibling_mem_sys->ref_mem_sys =
- child_mem_sys->ref_mem_sys;
+ if (child->sibling != NULL)
+ child->sibling->ref =
+ child->ref;
- *child_mem_sys->ref_mem_sys = child_mem_sys->sibling_mem_sys;
+ *child->ref = child->sibling;
/* Set this fields so destroy will work */
- child_mem_sys->ref_mem_sys = NULL;
- child_mem_sys->sibling_mem_sys = NULL;
+ child->ref = NULL;
+ child->sibling = NULL;
}
/* Visit all children and destroy them */
- child_mem_sys = mem_sys->child_mem_sys;
+ child = sms->child;
- while (child_mem_sys) {
- sibling_mem_sys = child_mem_sys->sibling_mem_sys;
- apr_sms_destroy(child_mem_sys);
- child_mem_sys = sibling_mem_sys;
+ while (child) {
+ sibling = child->sibling;
+ apr_sms_destroy(child);
+ child = sibling;
}
/*
* If the accounting memory system _is_ tracking, we also know that
* it is not the memory system itself.
*/
- if (apr_sms_is_tracking(mem_sys->accounting_mem_sys)) {
+ if (apr_sms_is_tracking(sms->accounting)) {
/*
* Run all cleanups, the memory will be freed by the destroying
* of the accounting memory system.
*/
- apr_sms_do_cleanups(mem_sys);
+ apr_sms_do_cleanups(sms);
/* Destroy the accounting memory system */
- apr_sms_destroy(mem_sys->accounting_mem_sys);
+ apr_sms_destroy(sms->accounting);
/*
* Set the accounting memory system back to the parent memory
* system just in case...
*/
- mem_sys->accounting_mem_sys = mem_sys;
+ sms->accounting = sms;
}
else {
/* Run all cleanups, free'ing memory as we go */
- cleanup = mem_sys->cleanups;
+ cleanup = sms->cleanups;
while (cleanup) {
cleanup->cleanup_fn(cleanup->data);
next_cleanup = cleanup->next;
- apr_sms_free(mem_sys->accounting_mem_sys, cleanup);
+ apr_sms_free(sms->accounting, cleanup);
cleanup = next_cleanup;
}
- if (mem_sys->accounting_mem_sys != mem_sys) {
+ if (sms->accounting != sms) {
/* Destroy the accounting memory system */
- apr_sms_destroy(mem_sys->accounting_mem_sys);
+ apr_sms_destroy(sms->accounting);
/*
* Set the accounting memory system back to the parent memory
* system just in case...
*/
- mem_sys->accounting_mem_sys = mem_sys;
+ sms->accounting = sms;
}
}
}
- pms = mem_sys->parent_mem_sys;
+ pms = sms->parent;
/* Remove the memory system from the parent memory systems child list */
if (pms)
apr_lock_acquire(pms->sms_lock);
- if (mem_sys->sibling_mem_sys)
- mem_sys->sibling_mem_sys->ref_mem_sys = mem_sys->ref_mem_sys;
+ if (sms->sibling)
+ sms->sibling->ref = sms->ref;
- if (mem_sys->ref_mem_sys)
- *mem_sys->ref_mem_sys = mem_sys->sibling_mem_sys;
+ if (sms->ref)
+ *sms->ref = sms->sibling;
if (pms)
apr_lock_release(pms->sms_lock);
/* Call the pre-destroy if present */
- if (mem_sys->pre_destroy_fn)
- mem_sys->pre_destroy_fn(mem_sys);
+ if (sms->pre_destroy_fn)
+ sms->pre_destroy_fn(sms);
- apr_lock_destroy(mem_sys->sms_lock);
+ apr_lock_destroy(sms->sms_lock);
/* XXX - This should eventually be removed */
- apr_pool_destroy(mem_sys->pool);
+ apr_pool_destroy(sms->pool);
/* 1 - If we have a self destruct, use it */
- if (mem_sys->destroy_fn)
- return mem_sys->destroy_fn(mem_sys);
+ if (sms->destroy_fn)
+ return sms->destroy_fn(sms);
/* 2 - If we don't have a parent, free using ourselves */
- if (!mem_sys->parent_mem_sys)
- return mem_sys->free_fn(mem_sys, mem_sys);
+ if (!sms->parent)
+ return sms->free_fn(sms, sms);
/* 3 - If we do have a parent and it has a free function, use it */
- if (mem_sys->parent_mem_sys->free_fn)
- return apr_sms_free(mem_sys->parent_mem_sys, mem_sys);
+ if (sms->parent->free_fn)
+ return apr_sms_free(sms->parent, sms);
/* 4 - Assume we are the child of a tracking memory system, do nothing */
#ifdef APR_ASSERT_MEMORY
- mem_sys = mem_sys->parent_mem_sys;
- while (mem_sys) {
- if (apr_sms_is_tracking(mem_sys))
+ sms = sms->parent;
+ while (sms) {
+ if (apr_sms_is_tracking(sms))
return APR_SUCCESS;
- mem_sys = mem_sys->parent_mem_sys;
+ sms = sms->parent;
}
assert(0); /* Made the wrong assumption, so we assert */
#endif /* APR_ASSERT_MEMORY */
@@ -497,39 +497,39 @@
#endif
while (b && b != a)
- b = b->parent_mem_sys;
+ b = b->parent;
/* APR_SUCCESS = 0, so if they agree we should return that... */
return !(b == a);
}
-APR_DECLARE(apr_status_t) apr_sms_lock(apr_sms_t *mem_sys)
+APR_DECLARE(apr_status_t) apr_sms_lock(apr_sms_t *sms)
{
/* If we don't have a lock_fn then we probably don't need one,
* so this is OK and we just return APR_SUCCESS
*/
- if (!mem_sys->lock_fn)
+ if (!sms->lock_fn)
return APR_SUCCESS;
- return mem_sys->lock_fn(mem_sys);
+ return sms->lock_fn(sms);
}
-APR_DECLARE(apr_status_t) apr_sms_unlock(apr_sms_t *mem_sys)
+APR_DECLARE(apr_status_t) apr_sms_unlock(apr_sms_t *sms)
{
/* If we don't have a lock_fn then we probably don't need one,
* so this is OK and we just return APR_SUCCESS
*/
- if (!mem_sys->unlock_fn)
+ if (!sms->unlock_fn)
return APR_SUCCESS;
- return mem_sys->unlock_fn(mem_sys);
+ return sms->unlock_fn(sms);
}
/*
* memory system cleanup management functions
*/
-APR_DECLARE(apr_status_t) apr_sms_cleanup_register(apr_sms_t *mem_sys,
+APR_DECLARE(apr_status_t) apr_sms_cleanup_register(apr_sms_t *sms,
apr_int32_t type,
void *data,
apr_status_t
@@ -540,14 +540,14 @@
if (!cleanup_fn)
return APR_ENOTIMPL;
- apr_lock_acquire(mem_sys->sms_lock);
+ apr_lock_acquire(sms->sms_lock);
cleanup = (struct apr_sms_cleanup *)
- apr_sms_malloc(mem_sys->accounting_mem_sys,
+ apr_sms_malloc(sms->accounting,
sizeof(struct apr_sms_cleanup));
if (!cleanup){
- apr_lock_release(mem_sys->sms_lock);
+ apr_lock_release(sms->sms_lock);
return APR_ENOMEM;
}
@@ -555,15 +555,15 @@
cleanup->type = type;
cleanup->cleanup_fn = cleanup_fn;
- cleanup->next = mem_sys->cleanups;
- mem_sys->cleanups = cleanup;
+ cleanup->next = sms->cleanups;
+ sms->cleanups = cleanup;
- apr_lock_release(mem_sys->sms_lock);
+ apr_lock_release(sms->sms_lock);
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister(apr_sms_t *mem_sys,
+APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister(apr_sms_t *sms,
apr_int32_t type,
void *data,
apr_status_t
@@ -573,19 +573,19 @@
struct apr_sms_cleanup **cleanup_ref;
apr_status_t rv = APR_EINVAL;
- apr_lock_acquire(mem_sys->sms_lock);
+ apr_lock_acquire(sms->sms_lock);
- cleanup = mem_sys->cleanups;
- cleanup_ref = &mem_sys->cleanups;
+ cleanup = sms->cleanups;
+ cleanup_ref = &sms->cleanups;
while (cleanup) {
if ((type == 0 || cleanup->type == type) &&
cleanup->data == data && cleanup->cleanup_fn == cleanup_fn) {
*cleanup_ref = cleanup->next;
- mem_sys = mem_sys->accounting_mem_sys;
+ sms = sms->accounting;
- if (mem_sys->free_fn)
- apr_sms_free(mem_sys, cleanup);
+ if (sms->free_fn)
+ apr_sms_free(sms, cleanup);
rv = APR_SUCCESS;
} else {
@@ -594,30 +594,30 @@
}
}
- apr_lock_release(mem_sys->sms_lock);
+ apr_lock_release(sms->sms_lock);
/* The cleanup function must have been registered previously */
return rv;
}
-APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister_type(apr_sms_t
*mem_sys,
+APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister_type(apr_sms_t *sms,
apr_int32_t type)
{
struct apr_sms_cleanup *cleanup;
struct apr_sms_cleanup **cleanup_ref;
apr_status_t rv = APR_EINVAL;
- apr_lock_acquire(mem_sys->sms_lock);
+ apr_lock_acquire(sms->sms_lock);
- cleanup = mem_sys->cleanups;
- cleanup_ref = &mem_sys->cleanups;
- mem_sys = mem_sys->accounting_mem_sys;
+ cleanup = sms->cleanups;
+ cleanup_ref = &sms->cleanups;
+ sms = sms->accounting;
while (cleanup) {
if (type == 0 || cleanup->type == type) {
*cleanup_ref = cleanup->next;
- if (mem_sys->free_fn)
- apr_sms_free(mem_sys, cleanup);
+ if (sms->free_fn)
+ apr_sms_free(sms, cleanup);
cleanup = *cleanup_ref;
rv = APR_SUCCESS;
@@ -628,13 +628,13 @@
}
}
- apr_lock_release(mem_sys->sms_lock);
+ apr_lock_release(sms->sms_lock);
/* The cleanup function must have been registered previously */
return rv;
}
-APR_DECLARE(apr_status_t) apr_sms_cleanup_run(apr_sms_t *mem_sys,
+APR_DECLARE(apr_status_t) apr_sms_cleanup_run(apr_sms_t *sms,
apr_int32_t type,
void *data,
apr_status_t
@@ -642,33 +642,33 @@
{
apr_status_t rv;
- if ((rv = apr_sms_cleanup_unregister(mem_sys, type,
+ if ((rv = apr_sms_cleanup_unregister(sms, type,
data, cleanup_fn)) != APR_SUCCESS)
return rv;
return cleanup_fn(data);
}
-APR_DECLARE(apr_status_t) apr_sms_cleanup_run_type(apr_sms_t *mem_sys,
+APR_DECLARE(apr_status_t) apr_sms_cleanup_run_type(apr_sms_t *sms,
apr_int32_t type)
{
struct apr_sms_cleanup *cleanup;
struct apr_sms_cleanup **cleanup_ref;
apr_status_t rv = APR_EINVAL;
- apr_lock_acquire(mem_sys->sms_lock);
+ apr_lock_acquire(sms->sms_lock);
- cleanup = mem_sys->cleanups;
- cleanup_ref = &mem_sys->cleanups;
- mem_sys = mem_sys->accounting_mem_sys;
+ cleanup = sms->cleanups;
+ cleanup_ref = &sms->cleanups;
+ sms = sms->accounting;
while (cleanup) {
if (type == 0 || cleanup->type == type) {
*cleanup_ref = cleanup->next;
cleanup->cleanup_fn(cleanup->data);
- if (mem_sys->free_fn)
- apr_sms_free(mem_sys, cleanup);
+ if (sms->free_fn)
+ apr_sms_free(sms, cleanup);
cleanup = *cleanup_ref;
rv = APR_SUCCESS;
@@ -679,13 +679,13 @@
}
}
- apr_lock_release(mem_sys->sms_lock);
+ apr_lock_release(sms->sms_lock);
/* The cleanup function should have been registered previously */
return rv;
}
-APR_DECLARE(const char*) apr_sms_identity(apr_sms_t *mem_sys)
+APR_DECLARE(const char*) apr_sms_identity(apr_sms_t *sms)
{
- return mem_sys->identity;
+ return sms->identity;
}
1.9 +17 -17 apr/memory/unix/apr_sms_std.c
Index: apr_sms_std.c
===================================================================
RCS file: /home/cvs/apr/memory/unix/apr_sms_std.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- apr_sms_std.c 2001/06/08 00:44:52 1.8
+++ apr_sms_std.c 2001/06/10 14:45:32 1.9
@@ -71,13 +71,13 @@
* standard memory system
*/
-static void *apr_sms_std_malloc(apr_sms_t *mem_sys,
+static void *apr_sms_std_malloc(apr_sms_t *sms,
apr_size_t size)
{
return malloc(size);
}
-static void *apr_sms_std_calloc(apr_sms_t *mem_sys,
+static void *apr_sms_std_calloc(apr_sms_t *sms,
apr_size_t size)
{
#if HAVE_CALLOC
@@ -91,50 +91,50 @@
}
-static void *apr_sms_std_realloc(apr_sms_t *mem_sys,
+static void *apr_sms_std_realloc(apr_sms_t *sms,
void *mem, apr_size_t size)
{
return realloc(mem, size);
}
-static apr_status_t apr_sms_std_free(apr_sms_t *mem_sys,
+static apr_status_t apr_sms_std_free(apr_sms_t *sms,
void *mem)
{
free(mem);
return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_sms_std_create(apr_sms_t **mem_sys)
+APR_DECLARE(apr_status_t) apr_sms_std_create(apr_sms_t **sms)
{
- apr_sms_t *new_mem_sys;
+ apr_sms_t *new_sms;
apr_status_t rv;
- *mem_sys = NULL;
+ *sms = NULL;
/* We don't have a parent so we allocate the memory
* for the structure ourselves...
*/
- new_mem_sys = apr_sms_std_calloc(NULL, sizeof(apr_sms_t));
+ new_sms = apr_sms_std_calloc(NULL, sizeof(apr_sms_t));
- if (!new_mem_sys)
+ if (!new_sms)
return APR_ENOMEM;
- if ((rv = apr_sms_init(new_mem_sys, NULL)) != APR_SUCCESS)
+ if ((rv = apr_sms_init(new_sms, NULL)) != APR_SUCCESS)
return rv;
- new_mem_sys->malloc_fn = apr_sms_std_malloc;
- new_mem_sys->calloc_fn = apr_sms_std_calloc;
- new_mem_sys->realloc_fn = apr_sms_std_realloc;
- new_mem_sys->free_fn = apr_sms_std_free;
- new_mem_sys->identity = module_identity;
+ new_sms->malloc_fn = apr_sms_std_malloc;
+ new_sms->calloc_fn = apr_sms_std_calloc;
+ new_sms->realloc_fn = apr_sms_std_realloc;
+ new_sms->free_fn = apr_sms_std_free;
+ new_sms->identity = module_identity;
/* as we're not a tracking memory module, i.e. we don't keep
* track of our allocations, we don't have apr_sms_reset or
* apr_sms_destroy functions.
*/
- apr_sms_assert(new_mem_sys);
+ apr_sms_assert(new_sms);
- *mem_sys = new_mem_sys;
+ *sms = new_sms;
return APR_SUCCESS;
}
1.9 +24 -24 apr/memory/unix/apr_sms_tracking.c
Index: apr_sms_tracking.c
===================================================================
RCS file: /home/cvs/apr/memory/unix/apr_sms_tracking.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- apr_sms_tracking.c 2001/06/08 00:44:52 1.8
+++ apr_sms_tracking.c 2001/06/10 14:45:32 1.9
@@ -88,18 +88,18 @@
apr_lock_t *lock;
} apr_sms_tracking_t;
-static void *apr_sms_tracking_malloc(apr_sms_t *mem_sys,
+static void *apr_sms_tracking_malloc(apr_sms_t *sms,
apr_size_t size)
{
apr_sms_tracking_t *tms;
apr_track_node_t *node;
- node = apr_sms_malloc(mem_sys->parent_mem_sys,
+ node = apr_sms_malloc(sms->parent,
size + sizeof(apr_track_node_t));
if (!node)
return NULL;
- tms = (apr_sms_tracking_t *)mem_sys;
+ tms = (apr_sms_tracking_t *)sms;
apr_lock_acquire(tms->lock);
node->next = tms->nodes;
@@ -115,18 +115,18 @@
return (void *)node;
}
-static void *apr_sms_tracking_calloc(apr_sms_t *mem_sys,
+static void *apr_sms_tracking_calloc(apr_sms_t *sms,
apr_size_t size)
{
apr_sms_tracking_t *tms;
apr_track_node_t *node;
- node = apr_sms_calloc(mem_sys->parent_mem_sys,
+ node = apr_sms_calloc(sms->parent,
size + sizeof(apr_track_node_t));
if (!node)
return NULL;
- tms = (apr_sms_tracking_t *)mem_sys;
+ tms = (apr_sms_tracking_t *)sms;
apr_lock_acquire(tms->lock);
node->next = tms->nodes;
@@ -142,13 +142,13 @@
return (void *)node;
}
-static void *apr_sms_tracking_realloc(apr_sms_t *mem_sys,
+static void *apr_sms_tracking_realloc(apr_sms_t *sms,
void *mem, apr_size_t size)
{
apr_sms_tracking_t *tms;
apr_track_node_t *node;
- tms = (apr_sms_tracking_t *)mem_sys;
+ tms = (apr_sms_tracking_t *)sms;
node = (apr_track_node_t *)mem;
@@ -164,7 +164,7 @@
apr_lock_release(tms->lock);
}
- node = apr_sms_realloc(mem_sys->parent_mem_sys,
+ node = apr_sms_realloc(sms->parent,
node, size + sizeof(apr_track_node_t));
if (!node)
return NULL;
@@ -184,7 +184,7 @@
return (void *)node;
}
-static apr_status_t apr_sms_tracking_free(apr_sms_t *mem_sys,
+static apr_status_t apr_sms_tracking_free(apr_sms_t *sms,
void *mem)
{
apr_track_node_t *node;
@@ -193,7 +193,7 @@
node = (apr_track_node_t *)mem;
node--;
- tms = (apr_sms_tracking_t *)mem_sys;
+ tms = (apr_sms_tracking_t *)sms;
apr_lock_acquire(tms->lock);
@@ -203,16 +203,16 @@
apr_lock_release(tms->lock);
- return apr_sms_free(mem_sys->parent_mem_sys, node);
+ return apr_sms_free(sms->parent, node);
}
-static apr_status_t apr_sms_tracking_reset(apr_sms_t *mem_sys)
+static apr_status_t apr_sms_tracking_reset(apr_sms_t *sms)
{
apr_sms_tracking_t *tms;
apr_track_node_t *node;
apr_status_t rv;
- tms = (apr_sms_tracking_t *)mem_sys;
+ tms = (apr_sms_tracking_t *)sms;
apr_lock_acquire(tms->lock);
@@ -221,7 +221,7 @@
*(node->ref) = node->next;
if (node->next)
node->next->ref = node->ref;
- if ((rv = apr_sms_free(mem_sys->parent_mem_sys,
+ if ((rv = apr_sms_free(sms->parent,
node)) != APR_SUCCESS) {
apr_lock_release(tms->lock);
return rv;
@@ -233,7 +233,7 @@
return APR_SUCCESS;
}
-static apr_status_t apr_sms_tracking_pre_destroy(apr_sms_t *mem_sys)
+static apr_status_t apr_sms_tracking_pre_destroy(apr_sms_t *sms)
{
/* This function WILL alwways be called. However, be aware that the
* main sms destroy function knows that it's not wise to try and destroy
@@ -243,7 +243,7 @@
*/
apr_sms_tracking_t *tms;
- tms = (apr_sms_tracking_t *)mem_sys;
+ tms = (apr_sms_tracking_t *)sms;
apr_lock_acquire(tms->lock);
apr_lock_destroy(tms->lock);
tms->lock = NULL;
@@ -251,13 +251,13 @@
return APR_SUCCESS;
}
-static apr_status_t apr_sms_tracking_destroy(apr_sms_t *mem_sys)
+static apr_status_t apr_sms_tracking_destroy(apr_sms_t *sms)
{
apr_status_t rv;
apr_sms_tracking_t *tms;
apr_track_node_t *node;
- tms = (apr_sms_tracking_t *)mem_sys;
+ tms = (apr_sms_tracking_t *)sms;
/* XXX - As we've already had the lock we've been using destroyed
* in the pre_destroy function we can't use it. However, if we
@@ -269,22 +269,22 @@
*(node->ref) = node->next;
if (node->next)
node->next->ref = node->ref;
- if ((rv = apr_sms_free(mem_sys->parent_mem_sys, node)) !=
APR_SUCCESS)
+ if ((rv = apr_sms_free(sms->parent, node)) != APR_SUCCESS)
return rv;
}
- return apr_sms_free(mem_sys->parent_mem_sys, mem_sys);
+ return apr_sms_free(sms->parent, sms);
}
-APR_DECLARE(apr_status_t) apr_sms_tracking_create(apr_sms_t **mem_sys,
+APR_DECLARE(apr_status_t) apr_sms_tracking_create(apr_sms_t **sms,
apr_sms_t *pms)
{
apr_sms_t *new_sms;
apr_sms_tracking_t *tms;
apr_status_t rv;
- *mem_sys = NULL;
+ *sms = NULL;
/* We're not a top level module, ie we have a parent, so
* we allocate the memory for the structure from our parent.
* This is safe as we shouldn't outlive our parent...
@@ -313,7 +313,7 @@
apr_sms_assert(new_sms);
- *mem_sys = new_sms;
+ *sms = new_sms;
return APR_SUCCESS;
}