summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordreid <dreid@13f79535-47bb-0310-9956-ffa450edef68>2001-05-13 14:43:49 +0000
committerdreid <dreid@13f79535-47bb-0310-9956-ffa450edef68>2001-05-13 14:43:49 +0000
commit74f274469d7276ae3d910000edacc43a456b5c90 (patch)
treef708fbc17faddee95b09ff0178abb82478fa35e6
parent8530951608cd115d1e28e5d5cfd9319f9c48cfd6 (diff)
downloadlibapr-74f274469d7276ae3d910000edacc43a456b5c90.tar.gz
This should get the memory code building again and also added
a patch from Sander Striker that gets apr_sms_destroy returning an apr_status_t correctly. Submitted by: Sander Striker <striker@samba-tng.org> Reviewed by: David Reid <dreid@apache.org> git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61628 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--include/apr_memory_system.h2
-rw-r--r--memory/unix/apr_memory_system.c11
-rw-r--r--memory/unix/apr_tracking_memory_system.c18
3 files changed, 19 insertions, 12 deletions
diff --git a/include/apr_memory_system.h b/include/apr_memory_system.h
index 46f6b7c46..d34ecc16b 100644
--- a/include/apr_memory_system.h
+++ b/include/apr_memory_system.h
@@ -98,7 +98,7 @@ struct apr_sms_t
apr_status_t (*free_fn)(apr_sms_t *mem_sys, void *memory);
apr_status_t (*reset_fn)(apr_sms_t *mem_sys);
void (*pre_destroy_fn)(apr_sms_t *mem_sys);
- void (*destroy_fn)(apr_sms_t *mem_sys);
+ apr_status_t (*destroy_fn)(apr_sms_t *mem_sys);
void (*threadsafe_lock_fn)(apr_sms_t *mem_sys);
void (*threadsafe_unlock_fn)(apr_sms_t *mem_sys);
};
diff --git a/memory/unix/apr_memory_system.c b/memory/unix/apr_memory_system.c
index 00b607956..820a68c18 100644
--- a/memory/unix/apr_memory_system.c
+++ b/memory/unix/apr_memory_system.c
@@ -169,9 +169,6 @@ APR_DECLARE(apr_status_t) apr_sms_free(apr_sms_t *mem_sys,
static int apr_sms_is_tracking(apr_sms_t *mem_sys)
{
-#ifdef APR_ASSERT_MEMORY
- assert(mem_sys->reset_fn);
-#endif
/*
* The presense of a reset function gives us the clue that this is a
* tracking memory system.
@@ -328,7 +325,7 @@ APR_DECLARE(apr_status_t) apr_sms_reset(apr_sms_t *mem_sys)
if (!mem_sys)
return APR_EMEMSYS;
if (!mem_sys->reset_fn)
- return APR_EMEMALLOCATOR;
+ return APR_EINVAL; /* Not sure if this is right... */
/*
* Run the cleanups of all child memory systems _including_
@@ -467,15 +464,15 @@ APR_DECLARE(apr_status_t) apr_sms_destroy(apr_sms_t *mem_sys)
/* 1 - If we have a self destruct, use it */
if (mem_sys->destroy_fn != NULL)
- mem_sys->destroy_fn(mem_sys);
+ return mem_sys->destroy_fn(mem_sys);
/* 2 - If we don't have a parent, free using ourselves */
else if (mem_sys->parent_mem_sys == NULL)
- mem_sys->free_fn(mem_sys, mem_sys);
+ return mem_sys->free_fn(mem_sys, mem_sys);
/* 3 - If we do have a parent and it has a free function, use it */
else if (mem_sys->parent_mem_sys->free_fn != NULL)
- apr_sms_free(mem_sys->parent_mem_sys, mem_sys);
+ return apr_sms_free(mem_sys->parent_mem_sys, mem_sys);
/* 4 - Assume we are the child of a tracking memory system, and do nothing */
#ifdef APR_ASSERT_MEMORY
diff --git a/memory/unix/apr_tracking_memory_system.c b/memory/unix/apr_tracking_memory_system.c
index afb369084..2beda942e 100644
--- a/memory/unix/apr_tracking_memory_system.c
+++ b/memory/unix/apr_tracking_memory_system.c
@@ -208,12 +208,22 @@ static apr_status_t apr_sms_tracking_reset(apr_sms_t *mem_sys)
return APR_SUCCESS;
}
-static void apr_sms_tracking_destroy(apr_sms_t *mem_sys)
+static apr_status_t apr_sms_tracking_destroy(apr_sms_t *mem_sys)
{
- assert (mem_sys != NULL);
+ apr_status_t rv;
+ /* If this is NULL we won't blow up as it should be caught at the
+ * next level down and then passed back to us...
+ */
+#ifdef APR_ASSERT_MEMORY
+ assert (mem_sys->parent_mem_sys != NULL);
+#endif
+
+ if (!mem_sys)
+ return APR_EMEMSYS;
- apr_sms_tracking_reset(mem_sys);
- apr_sms_free(mem_sys->parent_mem_sys, mem_sys);
+ if ((rv = apr_sms_tracking_reset(mem_sys)) != APR_SUCCESS)
+ return rv;
+ return apr_sms_free(mem_sys->parent_mem_sys, mem_sys);
}
APR_DECLARE(apr_status_t) apr_sms_tracking_create(apr_sms_t **mem_sys,