summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstriker <striker@13f79535-47bb-0310-9956-ffa450edef68>2001-09-28 14:05:23 +0000
committerstriker <striker@13f79535-47bb-0310-9956-ffa450edef68>2001-09-28 14:05:23 +0000
commitec6685c4749fc82947dbcd702c17812ce35b38d8 (patch)
tree20a4c33c52b44206303b031f67acea7960229f97
parent6801a353b064710323a94e7b53bfd0ca6f8da306 (diff)
downloadlibapr-ec6685c4749fc82947dbcd702c17812ce35b38d8.tar.gz
Remove SMS and all references.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@62381 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--STATUS45
-rw-r--r--apr.dsp28
-rw-r--r--configure.in11
-rw-r--r--include/apr.hw3
-rw-r--r--include/apr_pools.h41
-rw-r--r--include/apr_portable.h17
-rw-r--r--include/apr_sms.h439
-rw-r--r--include/apr_sms_blocks.h99
-rw-r--r--include/apr_sms_threads.h109
-rw-r--r--include/apr_sms_tracking.h97
-rw-r--r--include/apr_sms_trivial.h104
-rw-r--r--include/arch/netware/apr_private.h41
-rw-r--r--include/arch/unix/inherit.h24
-rw-r--r--include/arch/unix/locks.h1
-rw-r--r--include/arch/win32/apr_private.h41
-rw-r--r--libapr.dsp28
-rw-r--r--memory/unix/Makefile.in8
-rw-r--r--memory/unix/apr_sms.c1088
-rw-r--r--memory/unix/apr_sms_blocks.c280
-rw-r--r--memory/unix/apr_sms_pools.c220
-rw-r--r--memory/unix/apr_sms_std.c159
-rw-r--r--memory/unix/apr_sms_threads.c964
-rw-r--r--memory/unix/apr_sms_tracking.c291
-rw-r--r--memory/unix/apr_sms_trivial.c531
-rw-r--r--memory/unix/sms_private.h159
-rw-r--r--misc/netware/aprlib.imp33
-rw-r--r--test/testmem.c82
-rw-r--r--test/testud.c14
28 files changed, 15 insertions, 4942 deletions
diff --git a/STATUS b/STATUS
index b9837a626..ba7c003e8 100644
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
APACHE PORTABLE RUNTIME (APR) LIBRARY STATUS: -*-text-*-
-Last modified at [$Date: 2001/09/26 18:25:04 $]
+Last modified at [$Date: 2001/09/28 14:05:22 $]
Release:
@@ -138,17 +138,13 @@ RELEASE NON-SHOWSTOPPERS BUT WOULD BE REAL NICE TO WRAP THESE UP:
-- note on Win32 we distinguish 'apache module' names from other
'loadable module' names, so be careful with Apache's directive.
- * APR memory code - code has been added but we still need to
- - decide on a better name for the code
- - reformat to APR style (think this is now done, but some tabs left)
- - test on more systems
- - add more detailed tests to testmem.c
- Status: Optionally enable it with --enable-sms. Still wildly
- unproven. But, it actually works as a replacement for
- pools now. It may even not segfault when running httpd
- under high-loads. The performance impact/benefit still
- needs to be examined.
-
+ * APR memory code
+ The SMS code has been removed. The abstraction made it perform
+ far worse than pools. Pools need probably be revamped to take
+ a want_new_freelist parameter to get rid of the global locking
+ on block allocation.
+ Status: Sander volunteers
+
* In line with the new SMS code is the fact that threading and pools
just are not working together well. This is due to the fact that
the pool code has one global mutex (alloc_mutex) and one freelist
@@ -171,6 +167,7 @@ RELEASE NON-SHOWSTOPPERS BUT WOULD BE REAL NICE TO WRAP THESE UP:
There are other possibilities. Any of those probably
work as well. See the apr archives for more info.
We're still debating this.
+ Sander: The SMS code has been removed (see above).
* Possible gmtime_r replacement in explode_time
On Solaris (and possibly others), the gmtime_r libc function obtains
@@ -254,27 +251,3 @@ Stuff waiting for code thawing after Beta 1:
usefulness, perhaps hidden, generic read-only [immutable],
effective current user permissions, etc.
-APR Stackable Memory Code
-=========================
-
-This is just a small list of things yet to be done, or things
-that we may want/need to consider.
-
-- add a shared memory module.
-
-- locking needs to be addressed. The scope of the locks needs
- to be defined and it's likely we'll need some way of
- varying the scope when locking.
-
-- given the problems that can occur when trying to find
- alloc/free problems we should probably have a special debug
- memory system that records everything it does and any
- other information we think is useful.
-
-- in addition to the debugging system, we need to look at
- methods of checking memory allocations to ensure we're
- behaving when we have the ASSERT_MEMORY flag turned on.
- The pools in 1.3 had code from dean and Roy, Greg has added
- some special stuff for pools under Linux on 2.0, so we just
- need some ideas
-
diff --git a/apr.dsp b/apr.dsp
index e5c7746d3..c587d5cc9 100644
--- a/apr.dsp
+++ b/apr.dsp
@@ -188,26 +188,6 @@ SOURCE=.\locks\win32\thread_rwlock.c
SOURCE=.\memory\unix\apr_pools.c
# End Source File
-# Begin Source File
-
-SOURCE=.\memory\unix\apr_sms.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\memory\unix\apr_sms_blocks.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\memory\unix\apr_sms_std.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\memory\unix\apr_sms_tracking.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\memory\unix\apr_sms_trivial.c
-# End Source File
# End Group
# Begin Group "misc"
@@ -571,14 +551,6 @@ SOURCE=.\include\apr_signal.h
# End Source File
# Begin Source File
-SOURCE=.\include\apr_sms.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\apr_sms_tracking.h
-# End Source File
-# Begin Source File
-
SOURCE=.\include\apr_strings.h
# End Source File
# Begin Source File
diff --git a/configure.in b/configure.in
index 87eb4c16b..fd92f4088 100644
--- a/configure.in
+++ b/configure.in
@@ -179,17 +179,6 @@ if test "$host" = "i586-pc-beos"; then
) dnl
fi
-POOLS_TARGET=apr_pools.lo
-AC_ARG_ENABLE(sms, [ --enable-sms Build APR to use sms emulating pools],
- echo "************* WARNING ***************"
- echo "You have switched ON using SMS to emulate pools. This is highly"
- echo "experimental and so you may want to think about it!"
- echo "Presently this option is only advised for people working on SMS"
- APR_ADDTO(CPPFLAGS, -DAPR_POOLS_ARE_SMS)
- POOLS_TARGET=apr_sms_pools.lo
-)dnl
-AC_SUBST(POOLS_TARGET)
-
dnl # this is the place to put specific options for platform/compiler
dnl # combinations
case "$host:$CC" in
diff --git a/include/apr.hw b/include/apr.hw
index ba373e110..5f175d070 100644
--- a/include/apr.hw
+++ b/include/apr.hw
@@ -270,9 +270,8 @@ typedef int pid_t;
typedef int uid_t;
typedef int gid_t;
-
typedef struct apr_lock_t apr_lock_t;
-typedef struct apr_sms_t apr_sms_t;
+
/* Mechanisms to properly type numeric literals */
#define APR_INT64_C(val) (val##i64)
diff --git a/include/apr_pools.h b/include/apr_pools.h
index 4c1e1f317..13a340c94 100644
--- a/include/apr_pools.h
+++ b/include/apr_pools.h
@@ -55,10 +55,6 @@
#ifndef APR_POOLS_H
#define APR_POOLS_H
-#ifdef APR_POOLS_ARE_SMS
-#include "apr_sms.h"
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -99,13 +95,11 @@ extern "C" {
#define APR_POOL_DEBUG
*/
-#ifndef APR_POOLS_ARE_SMS
/** The fundamental pool type */
typedef struct apr_pool_t apr_pool_t;
/** A function that is called when allocation fails. */
typedef int (*apr_abortfunc_t)(int retcode);
-#endif /* !APR_POOLS_ARE_SMS */
/**
* @defgroup PoolDebug Pool Debugging functions.
@@ -238,7 +232,6 @@ APR_DECLARE(void) apr_pool_alloc_term(apr_pool_t *globalp);
APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newcont,
apr_pool_t *cont);
-#if !defined(APR_POOLS_ARE_SMS) || defined(DOXYGEN)
/**
* Set the function to be called when an allocation failure occurs.
* @tip If the program wants APR to exit on a memory allocation error,
@@ -330,8 +323,6 @@ APR_DECLARE(void *) apr_palloc(apr_pool_t *c, apr_size_t reqsize);
*/
APR_DECLARE(void *) apr_pcalloc(apr_pool_t *p, apr_size_t size);
-#endif /* !APR_POOLS_ARE_SMS || DOXYGEN */
-
/**
* @param p The new sub-pool
* @param parent The pool to use as a parent pool
@@ -357,7 +348,6 @@ APR_DECLARE(void) apr_pool_cleanup_register(apr_pool_t *p, const void *data,
apr_status_t (*plain_cleanup)(void *),
apr_status_t (*child_cleanup)(void *));
-#if !defined(APR_POOLS_ARE_SMS) || defined(DOXYGEN)
/**
* Remove a previously registered cleanup function
* @param p The pool remove the cleanup from
@@ -396,8 +386,6 @@ APR_DECLARE(apr_status_t) apr_pool_cleanup_run(apr_pool_t *p, void *data,
*/
APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data);
-#endif /* !APR_POOLS_ARE_SMS || DOXYGEN */
-
/* Preparing for exec() --- close files, etc., but *don't* flush I/O
* buffers, *don't* wait for subprocesses, and *don't* free any memory.
*/
@@ -447,35 +435,6 @@ APR_DECLARE(void) apr_pool_cleanup_for_exec(void);
# define apr_pool_join(a,b)
#endif /* APR_POOL_DEBUG */
-#ifdef APR_POOLS_ARE_SMS
-/* Add a number of defines where the sms equivalent is 1 to 1 */
-#define apr_pool_get_abort(p) apr_sms_get_abort(p)
-#define apr_pool_set_abort(fn, p) apr_sms_set_abort(fn, p)
-
-#define apr_pool_get_parent(p) apr_sms_get_parent(p)
-
-#define apr_pool_userdata_set(d, k, c, p) \
- apr_sms_userdata_set(d, k, c, p)
-#define apr_pool_userdata_get(d, k, p) \
- apr_sms_userdata_get(d, k, p)
-
-#define apr_pool_cleanup_kill(p, d, c) \
- apr_sms_cleanup_unregister(p, APR_ALL_CLEANUPS, d, c)
-#define apr_pool_cleanup_run(p, d, c) \
- apr_sms_cleanup_run(p, APR_GENERAL_CLEANUP, d, c)
-
-/* we won't even bother to register these as they'll be ignored when
- * we call the register fucntion
- */
-#define apr_pool_cleanup_null NULL
-
-/* The parameters match exactly for these, so just define them directly */
-#define apr_palloc apr_sms_malloc
-#define apr_pcalloc apr_sms_calloc
-#define apr_pool_clear apr_sms_reset
-#define apr_pool_destroy apr_sms_destroy
-
-#endif /* APR_POOLS_ARE_SMS */
/** @} */
#ifdef __cplusplus
}
diff --git a/include/apr_portable.h b/include/apr_portable.h
index 548112839..4888a26df 100644
--- a/include/apr_portable.h
+++ b/include/apr_portable.h
@@ -77,7 +77,6 @@
#include "apr_lock.h"
#include "apr_time.h"
#include "apr_dso.h"
-#include "apr_sms.h"
#if APR_HAVE_DIRENT_H
#include <dirent.h>
@@ -315,22 +314,6 @@ APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void);
APR_DECLARE(int) apr_os_thread_equal(apr_os_thread_t tid1,
apr_os_thread_t tid2);
-/**
- * Register the specified thread with an sms
- * @param sms The SMS to register with
- * @param thread The thread to register
- */
-APR_DECLARE(apr_status_t) apr_sms_thread_register(apr_sms_t *sms,
- apr_os_thread_t thread);
-
-/**
- * Unregister a thread from an sms
- * @param sms The sms to unregister from
- * @param thread The thread to be unregistered
- */
-APR_DECLARE(apr_status_t) apr_sms_thread_unregister(apr_sms_t *sms,
- apr_os_thread_t thread);
-
/** @} */
#endif /* APR_HAS_THREADS */
diff --git a/include/apr_sms.h b/include/apr_sms.h
deleted file mode 100644
index 0bac01b15..000000000
--- a/include/apr_sms.h
+++ /dev/null
@@ -1,439 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-/* This code kindly donated to APR by
- * Elrond <elrond@samba-tng.org>
- * Luke Kenneth Casson Leighton <lkcl@samba-tng.org>
- * Sander Striker <striker@samba-tng.org>
- *
- * May 2001
- */
-
-/**
- * @file apr_sms.h
- * @brief APR SMS Memory routines
- */
-/**
- * @defgroup APR_SMS SMS Stackable Memory allocation system
- * @ingroup APR
- * @{
- */
-
-#ifndef APR_SMS_H
-#define APR_SMS_H
-
-/**
- * @typedef apr_sms_t
- * @brief holds the internal details required to implement a SMS
- * @see sms_private.h
- */
-typedef struct apr_sms_t apr_sms_t;
-
-#include "apr.h"
-#include "apr_errno.h"
-#ifndef APR_POOLS_ARE_SMS
-#include "apr_pools.h"
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef APR_POOLS_ARE_SMS
-typedef struct apr_sms_t apr_pool_t;
-typedef int (*apr_abortfunc_t)(int retcode);
-#endif
-
-/**********************************************************************
- ** Defines
- **********************************************************************/
-
-/* The various types of cleanup's we can offer */
-#define APR_ALL_CLEANUPS 0x0000
-#define APR_GENERAL_CLEANUP 0x0001
-#define APR_CHILD_CLEANUP 0x0002
-
-/* Alignment macro's
- *
- * APR_ALIGN is only to be used to align on a power of 2 boundary
- */
-#define APR_ALIGN(size, boundary) \
- (((size) + ((boundary) - 1)) & ~((boundary) - 1))
-
-#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
-
-/**********************************************************************
- ** Debug options
- **********************************************************************/
-/*
- * One of the aims of SMS is to provide a large range of debugging
- * options.
- *
- * The options are normally turned off by having the define commented out.
- * To use, simply remove the define and rebuild!
- *
- * Function definitions are at the end of the file...
- */
-
-/* APR_DEBUG_TO_FILE
- * This will put all debug output into a file, that you can name
- * using the APR_DEBUG_FILE define. Normally this is set to setdout
- * and the output is simply printed there.
- */
-#define APR_DEBUG_TO_FILE 0
-#define APR_DEBUG_FILE "/tmp/sms_debug"
-
-/* APR_DEBUG_SHOW_STRUCTURE
- * This turns on a print of the ancestory of the SMS when
- * creating/destroying an SMS so its place in the world can be seen.
- */
-#define APR_DEBUG_SHOW_STRUCTURE 0
-
-/* APR_DEBUG_SHOW_FUNCTIONS
- * This turns on debug printing of every call to
- * apr_sms_create
- * apr_sms_destroy
- * apr_sms_reset
- *
- * Format of output is
- * CREATE - sms 0x0000000 [STANDARD] has been created
- */
-#define APR_DEBUG_SHOW_FUNCTIONS 0
-
-/* APR_DEBUG_TAG_SMS
- * Turn on the ability to give an SMS a "tag" that can be used to identify
- * it.
- */
-#define APR_DEBUG_TAG_SMS 0
-
-/* APR_DEBUG_ALLOCATIONS
- * This will record ALL calls made to
- * apr_sms_malloc
- * apr_sms_calloc
- * apr_sms_realloc
- * apr_sms_free
- * Details are put into the file specified in the APR_DEBUG_ALLOC_FILE
- * define
- */
-#define APR_DEBUG_ALLOCATIONS 0
-#define APR_DEBUG_ALLOC_FILE "/tmp/sms_alloc"
-
-/**
- * @package APR memory system
- */
-
-struct apr_sms_cleanup;
-
-/*
- * memory allocation functions
- */
-
-/**
- * Allocate a block of memory using a certain memory system
- * @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
- */
-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 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
- */
-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 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
- */
-APR_DECLARE(void *) apr_sms_realloc(apr_sms_t *sms, void *mem, apr_size_t size);
-
-/**
- * Free a block of memory
- * @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
- */
-APR_DECLARE(apr_status_t) apr_sms_free(apr_sms_t *sms, void *mem);
-
-/*
- * memory system functions
- */
-
-#ifdef APR_ASSERT_MEMORY
-
-/**
- * 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.
- */
-APR_DECLARE(void) apr_sms_assert(apr_sms_t *sms);
-#else
-#ifdef apr_sms_assert
-#undef apr_sms_assert
-#endif
-#define apr_sms_assert(sms)
-#endif /* APR_ASSERT_MEMORY */
-
-/**
- * Reset a memory system so it can be reused.
- * This will also run all cleanup functions associated with the memory system
- * @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 sms The memory system to be reset
- */
-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 sms The memory system to be destroyed
- */
-APR_DECLARE(apr_status_t) apr_sms_destroy(apr_sms_t *sms);
-
-/**
- * Perform thread-safe locking required whilst this memory system is modified
- * @param sms The memory system to be locked for thread-safety
- */
-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 sms The memory system to be released from thread-safety
- */
-APR_DECLARE(apr_status_t) apr_sms_unlock(apr_sms_t *sms);
-
-/**
- * Determine if memory system a is an ancestor of memory system b
- * @param a The memory system to search
- * @param b The memory system to search for
- * @return APR_SUCCESS if a is an ancestor of b, 1 if it isn't
- */
-APR_DECLARE(apr_status_t) apr_sms_is_ancestor(apr_sms_t *a, apr_sms_t *b);
-
-/**
- * Get the memory_system identity
- * @param sms The memory system to identify
- */
-APR_DECLARE(const char *) apr_sms_get_identity(apr_sms_t *sms);
-
-/**
- * Get the parent sms
- * @param sms the memory system to get the parent from
- */
-APR_DECLARE(apr_sms_t *) apr_sms_get_parent(apr_sms_t *sms);
-
-/**
- * Set the abort function. This is called when we fail to
- * fulfil an allocation request.
- * @tip If an app wants APR to exit on a memory allocation error
- * then this function can be called to set the callback to
- * use. If this function is not called then APR will return an error
- * and expect the app to deal with it.
- * @param abortfunc The function to call
- * @param sms The sms to register the function with
- */
-APR_DECLARE(void) apr_sms_set_abort(apr_abortfunc_t abortfunc,
- apr_sms_t *sms);
-
-/**
- * Get the abort function registered with the sms.
- * @param sms The sms to get the function for
- * @return The abort function registered
- */
-APR_DECLARE(apr_abortfunc_t) apr_sms_get_abort(apr_sms_t *sms);
-
-/**
- * Set user data into the current sms.
- * @param data The user data to insert
- * @param key The key to assign to this data
- * @param cleanup The cleanup program to use when cleaning up the data
- * @param sms The sms to inert the data into
- */
-APR_DECLARE(apr_status_t) apr_sms_userdata_set(const void *data,
- const char *key,
- apr_status_t (*cleanup)(void*),
- apr_sms_t *sms);
-
-/**
- * Get user data from an sms using the key it was registered with
- * @param data A pointer to the returned data
- * @param key The key to use to identify the data
- * @param sms The sms to get the data from
- */
-APR_DECLARE(apr_status_t) apr_sms_userdata_get(void **data, const char *key,
- apr_sms_t *sms);
-
-/*
- * memory system cleanup management functions
- */
-
-/**
- * Register a function to be called when a memory system is reset or destroyed
- * @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
- */
-APR_DECLARE(apr_status_t) apr_sms_cleanup_register(apr_sms_t *sms,
- apr_int32_t type,
- const void *data,
- apr_status_t (*cleanup_fn)(void *));
-
-/**
- * Unregister a previously registered cleanup function
- * @param sms The memory system the cleanup function is registered
- * with
- * @param type The type of the cleanup to unregister
- * @param type The type of cleanup to run
- * @param data The data associated with the cleanup function
- * @param cleanup_fn The registered cleanup function
- */
-APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister(apr_sms_t *sms,
- apr_int32_t type,
- const void *data,
- apr_status_t (*cleanup)(void *));
-
-/**
- * Unregister all previously registered cleanup functions of the specified type
- * @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.
- */
-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 sms 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
- */
-APR_DECLARE(apr_status_t) apr_sms_cleanup_run(apr_sms_t *sms,
- apr_int32_t type,
- const void *data,
- apr_status_t (*cleanup)(void *));
-
-/**
- * Run the specified type of cleanup functions immediately and unregister them
- * @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.
- */
-APR_DECLARE(apr_status_t) apr_sms_cleanup_run_type(apr_sms_t *sms,
- apr_int32_t type);
-
-/**********************************************************************
- ** Standard SMS module
- **********************************************************************/
-
-/**
- * Create a standard malloc/realloc/free memory system
- * @param sms A pointer to the created apr_sms_t*
- */
-APR_DECLARE(apr_status_t) apr_sms_std_create(apr_sms_t **sms);
-
-
-/**********************************************************************
- ** Debug routines
- **********************************************************************/
-
-/* NB These are only available if the debugging option has been turned on. */
-
-#if APR_DEBUG_SHOW_STRUCTURE
-/**
- * Show the heirachy of the sms
- * @param sms The sms to show the information for
- * @param direction Do we show up (to parent) or down (to children)
- */
-APR_DECLARE(void) apr_sms_show_structure(apr_sms_t *sms, int direction);
-#endif /* APR_DEBUG_SHOW_STRUCTURE */
-
-#if APR_DEBUG_TAG_SMS
-/**
- * Set the debugging tag for an sms
- * @param tag The tag to give the sms
- * @param sms The sms to apply the tag to
- */
-APR_DECLARE(void) apr_sms_tag(apr_sms_t *sms, const char *tag);
-#endif /* APR_DEBUG_TAG_SMS */
-
-#if APR_SMS_ALLOC_STATS
-APR_DECLARE(void) apr_sms_dump_stats(apr_sms_t *sms);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-/** @} */
-#endif /* !APR_SMS_H */
-
diff --git a/include/apr_sms_blocks.h b/include/apr_sms_blocks.h
deleted file mode 100644
index 84bd1e445..000000000
--- a/include/apr_sms_blocks.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-/* This code kindly donated to APR by
- * Elrond <elrond@samba-tng.org>
- * Luke Kenneth Casson Leighton <lkcl@samba-tng.org>
- * Sander Striker <striker@samba-tng.org>
- *
- * May 2001
- */
-
-#ifndef APR_BLOCKS_MEMORY_SYSTEM_H
-#define APR_BLOCKS_MEMORY_SYSTEM_H
-
-#include "apr.h"
-#include "apr_sms.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/**
- * @file apr_sms_blocks.h
- * @brief APR SMS Blocks Memory System
- */
-/**
- * @defgroup APR_SMS_Blocks Blocks SMS
- * @ingroup APR_SMS
- * @{
- */
-
-/**
- * Create an sms system that allocates blocks of a given size
- * as fast as possible and tracks their free'ing
- * @param sms A pointer to the returned apr_sms_t*
- * @param pms The parent memory system, used to allocate the memory
- * that we will be tracking.
- */
-APR_DECLARE(apr_status_t) apr_sms_blocks_create(apr_sms_t **sms,
- apr_sms_t *pms,
- apr_size_t block_size);
-
-
-/** @} */
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APR_BLOCKS_MEMORY_SYSTEM_H */
diff --git a/include/apr_sms_threads.h b/include/apr_sms_threads.h
deleted file mode 100644
index e03bd3179..000000000
--- a/include/apr_sms_threads.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#ifndef APR_SMS_THREADS_H
-#define APR_SMS_THREADS_H
-
-#include "apr.h"
-#include "apr_sms.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if APR_HAS_THREADS
- /**
- * @file apr_sms_threads.h
- * @brief APR SMS Threads Memory System
- */
-/**
- * @defgroup APR_SMS_Threads Threads SMS
- * @ingroup APR_SMS
- * @{
- */
-
-/**
- * Create a pool like malloc/free/reset memory system
- * @param mem_sys A pointer to the returned apr_sms_t*
- * @param pms The parent memory system, used to allocate the memory
- * that we will be threads.
- */
-APR_DECLARE(apr_status_t) apr_sms_threads_create(apr_sms_t **sms,
- apr_sms_t *pms);
-
-/**
- * Create a pool like malloc/free/reset memory system
- * @param mem_sys A pointer to the returned apr_sms_t*
- * @param pms The parent memory system, used to allocate the memory
- * that we will be threads.
- * @param min_alloc The minimal blocksize to allocate when getting
- * memory from the parent
- * @param min_free The minimal amount of memory to make sure is
- * free in an allocated block from the parent
- * @param max_free The amount of memory the sms may hold on to
- */
-APR_DECLARE(apr_status_t) apr_sms_threads_create_ex(apr_sms_t **sms,
- apr_sms_t *pms,
- apr_size_t min_alloc,
- apr_size_t min_free,
- apr_size_t max_free);
-
-/** @} */
-#endif /* APR_HAS_THREADS */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APR_SMS_THREADS_H */
diff --git a/include/apr_sms_tracking.h b/include/apr_sms_tracking.h
deleted file mode 100644
index f73d47736..000000000
--- a/include/apr_sms_tracking.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-/* This code kindly donated to APR by
- * Elrond <elrond@samba-tng.org>
- * Luke Kenneth Casson Leighton <lkcl@samba-tng.org>
- * Sander Striker <striker@samba-tng.org>
- *
- * May 2001
- */
-
-#ifndef APR_TRACKING_MEMORY_SYSTEM_H
-#define APR_TRACKING_MEMORY_SYSTEM_H
-
-#include "apr.h"
-#include "apr_sms.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/**
- * @file apr_sms_tracking.h
- * @brief APR SMS Tracking Memory System
- */
-/**
- * @defgroup APR_SMS_Tracking Tracking SMS
- * @ingroup APR_SMS
- * @{
- */
-
-/**
- * Create a standard malloc/realloc/free memory system
- * @param mem_sys A pointer to the returned apr_sms_t*
- * @param pms The parent memory system, used to allocate the memory
- * that we will be tracking.
- */
-APR_DECLARE(apr_status_t) apr_sms_tracking_create(apr_sms_t **mem_sys,
- apr_sms_t *pms);
-
-
-/** @} */
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APR_TRACKING_MEMORY_SYSTEM_H */
diff --git a/include/apr_sms_trivial.h b/include/apr_sms_trivial.h
deleted file mode 100644
index be560dd07..000000000
--- a/include/apr_sms_trivial.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#ifndef APR_SMS_TRIVIAL_H
-#define APR_SMS_TRIVIAL_H
-
-#include "apr.h"
-#include "apr_sms.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/**
- * @file apr_sms_trivial.h
- * @brief APR SMS Trivial Memory System
- */
-/**
- * @defgroup APR_SMS_Trivial Trivial SMS
- * @ingroup APR_SMS
- * @{
- */
-
-/**
- * Create a pool like malloc/free/reset memory system
- * @param mem_sys A pointer to the returned apr_sms_t*
- * @param pms The parent memory system, used to allocate the memory
- * that we will be trivial.
- */
-APR_DECLARE(apr_status_t) apr_sms_trivial_create(apr_sms_t **sms,
- apr_sms_t *pms);
-
-/**
- * Create a pool like malloc/free/reset memory system
- * @param mem_sys A pointer to the returned apr_sms_t*
- * @param pms The parent memory system, used to allocate the memory
- * that we will be trivial.
- * @param min_alloc The minimal blocksize to allocate when getting
- * memory from the parent
- * @param min_free The minimal amount of memory to make sure is
- * free in an allocated block from the parent
- * @param max_free The amount of memory the sms may hold on to
- */
-APR_DECLARE(apr_status_t) apr_sms_trivial_create_ex(apr_sms_t **sms,
- apr_sms_t *pms,
- apr_size_t min_alloc,
- apr_size_t min_free,
- apr_size_t max_free);
-/** @} */
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APR_SMS_TRIVIAL_H */
diff --git a/include/arch/netware/apr_private.h b/include/arch/netware/apr_private.h
index 460b13979..253b9c2b8 100644
--- a/include/arch/netware/apr_private.h
+++ b/include/arch/netware/apr_private.h
@@ -158,47 +158,6 @@ typedef void (Sigfunc)(int);
//unsigned __stdcall SignalHandling(void *);
//int thread_ready(void);
-/* Macros to deal with using either a pool or an sms
- * to do memory stuff...
- */
-#define APR_CLEANUP_REGISTER(struct, data, func, scope) \
- if (struct->pool) { \
- apr_pool_cleanup_register(struct->pool, data, func, scope); \
- } else { \
- apr_sms_cleanup_register(struct->mem_sys, APR_CHILD_CLEANUP, \
- data, func); \
- }
-
-#define APR_CLEANUP_REMOVE(struct, data, func) \
- if (struct->pool) { \
- apr_pool_cleanup_kill(struct->pool, data, func); \
- } else { \
- apr_sms_cleanup_unregister(struct->mem_sys, APR_CHILD_CLEANUP, \
- data, func); \
- }
-
-#define APR_MEM_PSTRDUP(struct, ptr, str) \
- if (struct->pool) { \
- ptr = apr_pstrdup(struct->pool, str); \
- } else { \
- size_t len = strlen(str) + 1; \
- ptr = (char*) apr_sms_calloc(struct->mem_sys, len); \
- memcpy(ptr, str, len); \
- }
-
-#define APR_MEM_MALLOC(ptr, struct, type) \
- if (struct->pool) { \
- ptr = (type *)apr_palloc(struct->pool, sizeof(type)); \
- } else { \
- ptr = (type *)apr_sms_malloc(struct->mem_sys, sizeof(type)); \
- }
-
-#define APR_MEM_CALLOC(ptr, struct, type) \
- if (struct->pool) { \
- ptr = (type *)apr_pcalloc(struct->pool, sizeof(type)); \
- } else { \
- ptr = (type *)apr_sms_calloc(struct->mem_sys, sizeof(type)); \
- }
#endif /*APR_PRIVATE_H*/
#endif /*NETWARE*/
diff --git a/include/arch/unix/inherit.h b/include/arch/unix/inherit.h
index d268bfa2a..394c2cd5b 100644
--- a/include/arch/unix/inherit.h
+++ b/include/arch/unix/inherit.h
@@ -59,7 +59,6 @@
#define APR_INHERIT (2^24) /* Must not conflicts with other bits */
-#ifndef APR_POOLS_ARE_SMS
#define APR_IMPLEMENT_SET_INHERIT(name, flag, pool, cleanup) \
void apr_##name##_set_inherit(apr_##name##_t *name) \
{ \
@@ -69,19 +68,7 @@ void apr_##name##_set_inherit(apr_##name##_t *name) \
cleanup, apr_pool_cleanup_null); \
} \
}
-#else
-#define APR_IMPLEMENT_SET_INHERIT(name, flag, pool, cleanup) \
-void apr_##name##_set_inherit(apr_##name##_t *name) \
-{ \
- if (!(name->flag & APR_INHERIT)) { \
- name->flag |= APR_INHERIT; \
- apr_sms_cleanup_unregister(name->pool, APR_CHILD_CLEANUP, \
- (void *)name, cleanup); \
- } \
-}
-#endif
-#ifndef APR_POOLS_ARE_SMS
#define APR_IMPLEMENT_UNSET_INHERIT(name, flag, pool, cleanup) \
void apr_##name##_unset_inherit(apr_##name##_t *name) \
{ \
@@ -91,16 +78,5 @@ void apr_##name##_unset_inherit(apr_##name##_t *name) \
cleanup, cleanup); \
} \
}
-#else
-#define APR_IMPLEMENT_UNSET_INHERIT(name, flag, pool, cleanup) \
-void apr_##name##_unset_inherit(apr_##name##_t *name) \
-{ \
- if (name->flag & APR_INHERIT) { \
- name->flag &= ~APR_INHERIT; \
- apr_sms_cleanup_register(name->pool, APR_CHILD_CLEANUP, \
- (void *)name, cleanup); \
- } \
-}
-#endif
#endif /* ! INHERIT_H */
diff --git a/include/arch/unix/locks.h b/include/arch/unix/locks.h
index 47f089c14..6ef1c83d9 100644
--- a/include/arch/unix/locks.h
+++ b/include/arch/unix/locks.h
@@ -60,7 +60,6 @@
#include "apr_general.h"
#include "apr_lib.h"
#include "apr_lock.h"
-#include "apr_sms.h"
#include "apr_portable.h"
#include "proc_mutex.h"
diff --git a/include/arch/win32/apr_private.h b/include/arch/win32/apr_private.h
index d3affa890..884bedcd0 100644
--- a/include/arch/win32/apr_private.h
+++ b/include/arch/win32/apr_private.h
@@ -149,47 +149,6 @@ typedef void (Sigfunc)(int);
unsigned __stdcall SignalHandling(void *);
int thread_ready(void);
-/* Macros to deal with using either a pool or an sms
- * to do memory stuff...
- */
-#define APR_CLEANUP_REGISTER(struct, data, func, scope) \
- if (struct->pool) { \
- apr_pool_cleanup_register(struct->pool, data, func, scope); \
- } else { \
- apr_sms_cleanup_register(struct->mem_sys, APR_CHILD_CLEANUP, \
- data, func); \
- }
-
-#define APR_CLEANUP_REMOVE(struct, data, func) \
- if (struct->pool) { \
- apr_pool_cleanup_kill(struct->pool, data, func); \
- } else { \
- apr_sms_cleanup_unregister(struct->mem_sys, APR_CHILD_CLEANUP, \
- data, func); \
- }
-
-#define APR_MEM_PSTRDUP(struct, ptr, str) \
- if (struct->pool) { \
- ptr = apr_pstrdup(struct->pool, str); \
- } else { \
- size_t len = strlen(str) + 1; \
- ptr = (char*) apr_sms_calloc(struct->mem_sys, len); \
- memcpy(ptr, str, len); \
- }
-
-#define APR_MEM_MALLOC(ptr, struct, type) \
- if (struct->pool) { \
- ptr = (type *)apr_palloc(struct->pool, sizeof(type)); \
- } else { \
- ptr = (type *)apr_sms_malloc(struct->mem_sys, sizeof(type)); \
- }
-
-#define APR_MEM_CALLOC(ptr, struct, type) \
- if (struct->pool) { \
- ptr = (type *)apr_pcalloc(struct->pool, sizeof(type)); \
- } else { \
- ptr = (type *)apr_sms_calloc(struct->mem_sys, sizeof(type)); \
- }
#endif /*APR_PRIVATE_H*/
#endif /*WIN32*/
diff --git a/libapr.dsp b/libapr.dsp
index cc6259668..3a35e9e81 100644
--- a/libapr.dsp
+++ b/libapr.dsp
@@ -190,26 +190,6 @@ SOURCE=.\locks\win32\thread_rwlock.c
SOURCE=.\memory\unix\apr_pools.c
# End Source File
-# Begin Source File
-
-SOURCE=.\memory\unix\apr_sms.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\memory\unix\apr_sms_blocks.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\memory\unix\apr_sms_std.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\memory\unix\apr_sms_tracking.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\memory\unix\apr_sms_trivial.c
-# End Source File
# End Group
# Begin Group "misc"
@@ -573,14 +553,6 @@ SOURCE=.\include\apr_signal.h
# End Source File
# Begin Source File
-SOURCE=.\include\apr_sms.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\apr_sms_tracking.h
-# End Source File
-# Begin Source File
-
SOURCE=.\include\apr_strings.h
# End Source File
# Begin Source File
diff --git a/memory/unix/Makefile.in b/memory/unix/Makefile.in
index 7a122dc00..b390d746a 100644
--- a/memory/unix/Makefile.in
+++ b/memory/unix/Makefile.in
@@ -1,11 +1,5 @@
-TARGETS = apr_sms.lo \
- apr_sms_std.lo \
- apr_sms_tracking.lo \
- apr_sms_blocks.lo \
- apr_sms_trivial.lo \
- apr_sms_threads.lo \
- @POOLS_TARGET@
+TARGETS = apr_pools.lo
# bring in rules.mk for standard functionality
@INCLUDE_RULES@
diff --git a/memory/unix/apr_sms.c b/memory/unix/apr_sms.c
deleted file mode 100644
index c05d6d6e2..000000000
--- a/memory/unix/apr_sms.c
+++ /dev/null
@@ -1,1088 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-/* This code kindly donated to APR by
- * Elrond <elrond@samba-tng.org>
- * Luke Kenneth Casson Leighton <lkcl@samba-tng.org>
- * Sander Striker <striker@samba-tng.org>
- *
- * May 2001
- */
-
-#include "apr.h"
-#include "apr_general.h"
-#include "apr_sms.h"
-#include <stdlib.h>
-#include "apr_hash.h"
-#include "apr_strings.h"
-#include "apr_portable.h"
-
-#include "sms_private.h"
-
-#ifdef APR_ASSERT_MEMORY
-#include <assert.h>
-#endif
-#include <stdio.h>
-
-#include <memory.h> /* strikerXXX: had to add this for windows to stop
- * complaining, please autoconf the include stuff
- */
-
-FILE *dbg_file;
-
-/*
- * private structure defenitions
- */
-struct apr_sms_cleanup
-{
- struct apr_sms_cleanup *next;
- apr_int32_t type;
- const void *data;
- apr_status_t (*cleanup_fn)(void *);
-};
-
-#if APR_DEBUG_ALLOCATIONS
-FILE *alloc_file = NULL;
-
-static void _record_(apr_sms_t *sms, const char *what, apr_size_t size,
- void *ptr)
-{
- if (!alloc_file)
- return;
-
- if (ptr) {
-#if APR_DEBUG_TAG_SMS
- fprintf(alloc_file, "%10s %p '%9s' [%9s] @ %p\n",
- what, sms, sms->tag, sms->identity, ptr);
-#else
- fprintf(alloc_file, "%10s %p [%9s] @ %p\n",
- what, sms, sms->identity, ptr);
-#endif
- } else {
-#if APR_DEBUG_TAG_SMS
- fprintf(alloc_file, "%10s %p '%9s' [%9s] %6" APR_SIZE_T_FMT " bytes\n",
- what, sms, sms->tag, sms->identity, size);
-#else
- fprintf(alloc_file, "%10s %p [%9s] %6" APR_SIZE_T_FMT " bytes\n",
- what, sms, sms->identity, size);
-#endif
- }
- fflush(alloc_file);
-}
-#endif
-
-
-/*
- * memory allocation functions
- */
-
-APR_DECLARE(void *) apr_sms_malloc(apr_sms_t *sms,
- apr_size_t size)
-{
- if (size == 0)
- return NULL;
-
-#if APR_DEBUG_ALLOCATIONS
- _record_(sms, "MALLOC", size, NULL);
-#endif
-
- return sms->malloc_fn(sms, size);
-}
-
-APR_DECLARE(void *) apr_sms_calloc(apr_sms_t *sms,
- apr_size_t size)
-{
- if (size == 0)
- return NULL;
-
-#if APR_DEBUG_ALLOCATIONS
- _record_(sms, "CALLOC", size, NULL);
-#endif
-
- return sms->calloc_fn(sms, size);
-}
-
-APR_DECLARE(void *) apr_sms_realloc(apr_sms_t *sms, void *mem,
- apr_size_t size)
-{
-#if APR_DEBUG_ALLOCATIONS
- _record_(sms, "REALLOC", size, NULL);
-#endif
-
- if (!mem)
- return apr_sms_malloc(sms, size);
-
- if (size == 0) {
- apr_sms_free(sms, mem);
- return NULL;
- }
-
- if (sms->realloc_fn)
- return sms->realloc_fn(sms, mem, size);
-
- /* XXX - should we free the block passed in ??? */
- return NULL;
-}
-
-APR_DECLARE(apr_status_t) apr_sms_free(apr_sms_t *sms,
- void *mem)
-{
-
-#if APR_DEBUG_ALLOCATIONS
- _record_(sms, "FREE", 0, mem);
-#endif
-
- if (sms->free_fn)
- return sms->free_fn(sms, mem);
-
- /*
- * If there is no free_fn, this sms is a tracking memory
- * system by definition. In other words, it is ok
- * to return APR_SUCCESS because the memory will be
- * free()d by the reset or destroy.
- */
- return APR_SUCCESS;
-}
-
-/*
- * default allocation functions
- */
-
-static void *apr_sms_default_calloc(apr_sms_t *sms,
- apr_size_t size)
-{
- void *mem;
-
- mem = sms->malloc_fn(sms, size);
- if (mem)
- memset(mem, '\0', size);
-
- return mem;
-}
-
-/*
- * memory system functions
- */
-
-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 sms->reset_fn != NULL;
-}
-
-APR_DECLARE(apr_status_t) apr_sms_init(apr_sms_t *sms,
- apr_sms_t *pms)
-{
-#if APR_DEBUG_TO_FILE
- if (!dbg_file)
- dbg_file = fopen(APR_DEBUG_FILE, "w");
-#else
- dbg_file = stdout;
-#endif
-#if APR_DEBUG_ALLOCATIONS
- if (!alloc_file)
- alloc_file = fopen(APR_DEBUG_ALLOC_FILE, "w");
-#endif
-
- /* XXX - I've assumed that memory passed in will be zeroed,
- * i.e. calloc'd instead of malloc'd...
- * This may well be a bogus assumption, and if so we either need
- * to memset or have a series of =NULL's at the end.
- * This function is only called by modules, so this isn't as crazy
- * an assumption to make as it sounds :)
- */
-
- sms->parent = pms;
- sms->accounting = sms;
- sms->child = NULL;
-
- /*
- * Child memory systems are always linked to their parents. This works
- * as follows...
- *
- * parent
- * |
- * |
- * child --- sibling --- sibling --- sibling
- *
- * To be able to remove a memory system from a list we also need to
- * keep a ref pointer (a pointer to the pointer pointing to the memory
- * system). To remove a memory system, basically...
- *
- * *ref = sibling;
- * if (sibling)
- * sibling->ref = ref;
- */
-
- if (pms) {
- /*
- * We only need to lock the parent as the only other function that
- * touches the fields we're about to mess with is apr_sms_destroy
- */
- if (pms->sms_lock)
- apr_lock_acquire(pms->sms_lock);
-
- if ((sms->sibling = pms->child) != NULL)
- sms->sibling->ref = &sms->sibling;
-
- sms->ref = &pms->child;
- pms->child = sms;
-
- if (pms->sms_lock)
- apr_lock_release(pms->sms_lock);
- }
-
- /* Set default functions. These should NOT be altered by an sms
- * module unless it implements them itself.
- */
- sms->calloc_fn = apr_sms_default_calloc;
-
-#if APR_HAS_THREADS
- sms->threads = 1;
-#endif /* APR_HAS_THREADS */
-
-#ifndef APR_POOLS_ARE_SMS
- /* XXX - This should eventually be removed */
- apr_pool_create(&sms->pool, pms ? pms->pool : NULL);
-#else
- sms->pool = sms;
-#endif
-
- return APR_SUCCESS;
-}
-
-APR_DECLARE(apr_status_t) apr_sms_post_init(apr_sms_t *sms)
-{
- /* We do things here as these may potentially make calls
- * to the sms that we're creating, and if we make the calls
- * in the sms_init phase we haven't yet added the function
- * pointers so we'll segfault!
- */
- apr_status_t rv;
-
- apr_sms_assert(sms);
-
- rv = APR_SUCCESS;
-
-#if APR_HAS_THREADS
- apr_sms_thread_register(sms, apr_os_thread_current());
-#endif /* APR_HAS_THREADS */
-
-#if APR_DEBUG_SHOW_FUNCTIONS
- fprintf(dbg_file, "CREATE - sms %p [%s] has been created\n",
- sms, sms->identity);
-#endif
-#if APR_DEBUG_SHOW_STRUCTURE
- apr_sms_show_structure(sms, 1);
-#endif /* APR_DEBUG_SHOW_STRUCTURE */
-
- return rv;
-}
-
-
-#ifdef APR_ASSERT_MEMORY
-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(sms->malloc_fn);
-
- /*
- * Check to see if this is either a non-tracking or
- * a tracking memory system. It has to have at least a free
- * or destroy function. And to avoid half implementations
- * we require reset to be present when destroy is.
- */
- assert(sms->free_fn || (sms->destroy_fn && sms->reset_fn));
-
- assert(!sms->destroy_fn || sms->reset_fn);
-
- assert(!sms->reset_fn || sms->destroy_fn);
-
- /* Has someone been stupid and NULL'd our default function without
- * providing an implementation of their own... tsch, tsch
- */
- assert(sms->calloc_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(sms->accounting == sms ||
- sms->accounting->parent == sms);
-
- /*
- * A non-tracking memory system can be the child of
- * another non-tracking memory system if there are no
- * tracking ancestors, but in that specific case we issue a
- * warning.
- */
- if (!sms->parent)
- return;
-
- parent = sms;
- while (parent) {
- if (apr_sms_is_tracking(parent))
- return; /* Tracking memory system found, return satisfied ;-) */
-
- parent = parent->parent;
- }
-
- /* issue a warning:
- * WARNING: A non-tracking memory system was created without a tracking
- * parent.
- */
-}
-#endif /* APR_ASSERT_MEMORY */
-
-/*
- * LOCAL FUNCTION used in:
- * - apr_sms_do_child_cleanups
- * - apr_sms_reset
- * - apr_sms_destroy
- *
- * Call all the cleanup routines registered with a memory system.
- */
-static void apr_sms_do_cleanups(struct apr_sms_cleanup *c)
-{
- while (c) {
- if (c->type == APR_ALL_CLEANUPS || c->type == APR_GENERAL_CLEANUP) {
- c->cleanup_fn((void*)c->data);
- }
- c = c->next;
- }
-}
-
-/*
- * LOCAL FUNCTION used in:
- * - apr_sms_reset
- * - apr_sms_destroy
- *
- * This not only calls do_cleanups, but also calls the pre_destroy(!)
- */
-static void apr_sms_do_child_cleanups(apr_sms_t *sms)
-{
- while (sms) {
- apr_sms_do_child_cleanups(sms->child);
- apr_sms_do_cleanups(sms->cleanups);
- /*
- * We assume that all of our children & their siblings are created
- * from memory we've allocated, and as we're about to nuke it all
- * we need to run the pre_destroy so things like locks can be
- * cleaned up so we don't leak.
- * However, we aren't going to call destroy on a reset as we're about
- * to nuke them when we do the reset. This is why all "leakable"
- * items created in an sms module MUST be cleaned up in the
- * pre_destroy not the destroy.
- */
- if (sms->pre_destroy_fn != NULL)
- sms->pre_destroy_fn(sms);
- sms = sms->sibling;
- }
-}
-
-APR_DECLARE(apr_status_t) apr_sms_reset(apr_sms_t *sms)
-{
- apr_status_t rv;
-
- if (!sms->reset_fn)
- return APR_ENOTIMPL;
-
-#if APR_DEBUG_SHOW_FUNCTIONS
-# if APR_DEBUG_TAG_SMS
- fprintf(dbg_file, "RESET - sms %p '%s' [%s] being reset\n", sms,
- sms->tag, sms->identity);
-# else
- fprintf(dbg_file, "RESET - sms %p [%s] being reset\n", sms, sms->identity);
-# endif
-#endif
-
- if (sms->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(sms->child);
-
- /* Run all cleanups, the memory will be freed by the reset */
- apr_sms_do_cleanups(sms->cleanups);
- sms->cleanups = NULL;
-
- /* We don't have any child memory systems after the reset */
- sms->child = NULL;
-
- /* Reset the accounting memory system to ourselves, any
- * child memory system _including_ the accounting memory
- * system will be destroyed by the reset
- * strikerXXX: Maybe this should be the responsibility of
- * the reset function(?).
- */
- sms->accounting = sms;
-
- /* Let the memory system handle the actual reset */
- rv = sms->reset_fn(sms);
-
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- return rv;
-}
-
-APR_DECLARE(apr_status_t) apr_sms_destroy(apr_sms_t *sms)
-{
- apr_sms_t *child;
- apr_sms_t *sibling;
- apr_sms_t *pms;
- struct apr_sms_cleanup *cleanup;
- struct apr_sms_cleanup *next_cleanup;
-
-#if APR_DEBUG_SHOW_FUNCTIONS
- fprintf(dbg_file, "DESTROY - sms %p [%s] being destroyed\n",
- sms, sms->identity);
-#endif /* APR_DEBUG_SHOW_FUNCTIONS */
-#if APR_DEBUG_SHOW_STRUCTURE
- fprintf(dbg_file, "The following SMS will be destroyed by this action:\n");
- apr_sms_show_structure(sms, 0);
-#endif /* APR_DEBUG_SHOW_STRUCTURE */
-
- if (sms->sms_lock)
- apr_lock_acquire(sms->sms_lock);
-
- if (apr_sms_is_tracking(sms)) {
- /*
- * Run the cleanups of all child memory systems _including_
- * the accounting memory system.
- * This also does the pre_destroy functions in the children.
- */
- apr_sms_do_child_cleanups(sms->child);
-
- /* Run all cleanups, the memory will be freed by the destroy */
- apr_sms_do_cleanups(sms->cleanups);
- }
- else {
- 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->sibling != NULL)
- child->sibling->ref = child->ref;
-
- *child->ref = child->sibling;
-
- /* Set this fields so destroy will work */
- child->ref = NULL;
- child->sibling = NULL;
- }
-
- /* Visit all children and destroy them */
- child = sms->child;
-
- 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(sms->accounting)) {
- /*
- * Run all cleanups, the memory will be freed by the destroying
- * of the accounting memory system.
- */
- apr_sms_do_cleanups(sms->cleanups);
-
- /* Destroy the accounting memory system */
- apr_sms_destroy(sms->accounting);
-
- /*
- * Set the accounting memory system back to the parent memory
- * system just in case...
- */
- sms->accounting = sms;
- }
- else {
- /* Run all cleanups, free'ing memory as we go */
- cleanup = sms->cleanups;
-
- while (cleanup) {
- if (cleanup->type == APR_GENERAL_CLEANUP)
- cleanup->cleanup_fn((void*)cleanup->data);
-
- next_cleanup = cleanup->next;
- apr_sms_free(sms->accounting, cleanup);
- cleanup = next_cleanup;
- }
-
- if (sms->accounting != sms) {
- /* Destroy the accounting memory system */
- apr_sms_destroy(sms->accounting);
-
- /*
- * Set the accounting memory system back to the parent memory
- * system just in case...
- */
- sms->accounting = sms;
- }
- }
- }
-
- pms = sms->parent;
-
- /* Remove the memory system from the parent memory systems child list */
- if (pms) {
- if (pms->sms_lock)
- apr_lock_acquire(pms->sms_lock);
-
- if ((*sms->ref = sms->sibling) != NULL)
- sms->sibling->ref = sms->ref;
-
- if (pms->sms_lock)
- apr_lock_release(pms->sms_lock);
- }
-
- /* Call the pre-destroy if present */
- if (sms->pre_destroy_fn)
- sms->pre_destroy_fn(sms);
-
- if (sms->sms_lock)
- {
- apr_lock_destroy(sms->sms_lock);
- }
-
-#ifndef APR_POOLS_ARE_SMS
- /* XXX - This should eventually be removed */
- apr_pool_destroy(sms->pool);
-#endif
-
- /* 1 - If we have a self destruct, use it */
- if (sms->destroy_fn)
- return sms->destroy_fn(sms);
-
- /* 2 - If we don't have a parent, free using ourselves */
- if (!pms)
- return sms->free_fn(sms, sms);
-
- /* 3 - If we do have a parent and it has a free function, use it */
- if (pms->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
- sms = pms;
- while (sms) {
- if (apr_sms_is_tracking(sms))
- return APR_SUCCESS;
-
- sms = sms->parent;
- }
- assert(0); /* Made the wrong assumption, so we assert */
-#endif /* APR_ASSERT_MEMORY */
-
- return APR_SUCCESS;
-}
-
-APR_DECLARE(apr_status_t) apr_sms_is_ancestor(apr_sms_t *a,
- apr_sms_t *b)
-{
-#ifdef APR_ASSERT_MEMORY
- assert(a);
-#endif
-
- while (b && b != a)
- 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 *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 (!sms->lock_fn)
- return APR_SUCCESS;
-
- return sms->lock_fn(sms);
-}
-
-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 (!sms->unlock_fn)
- return APR_SUCCESS;
-
- return sms->unlock_fn(sms);
-}
-
-/*
- * memory system cleanup management functions
- */
-
-APR_DECLARE(apr_status_t) apr_sms_cleanup_register(apr_sms_t *sms,
- apr_int32_t type,
- const void *data,
- apr_status_t
- (*cleanup_fn)(void *))
-{
- struct apr_sms_cleanup *cleanup;
-
- if (!cleanup_fn)
- return APR_ENOTIMPL;
-
- if (sms->sms_lock)
- apr_lock_acquire(sms->sms_lock);
-
- cleanup = apr_sms_malloc(sms->accounting, sizeof(struct apr_sms_cleanup));
-
- if (!cleanup) {
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- return APR_ENOMEM;
- }
-
- cleanup->data = data;
- cleanup->type = type;
- cleanup->cleanup_fn = cleanup_fn;
-
- cleanup->next = sms->cleanups;
- sms->cleanups = cleanup;
-
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- return APR_SUCCESS;
-}
-
-APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister(apr_sms_t *sms,
- apr_int32_t type,
- const void *data,
- apr_status_t
- (*cleanup_fn)(void *))
-{
- struct apr_sms_cleanup *cleanup;
- struct apr_sms_cleanup **cleanup_ref;
- apr_status_t rv = APR_EINVAL;
-
- if (sms->sms_lock)
- apr_lock_acquire(sms->sms_lock);
-
- cleanup = sms->cleanups;
- cleanup_ref = &sms->cleanups;
- while (cleanup) {
- if ((type == APR_ALL_CLEANUPS || cleanup->type == type) &&
- cleanup->data == data && cleanup->cleanup_fn == cleanup_fn) {
- *cleanup_ref = cleanup->next;
-
- sms = sms->accounting;
-
- if (sms->free_fn)
- apr_sms_free(sms, cleanup);
-
- cleanup = *cleanup_ref;
- rv = APR_SUCCESS;
- } else {
- cleanup_ref = &cleanup->next;
- cleanup = cleanup->next;
- }
- }
-
- if (sms->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 *sms,
- apr_int32_t type)
-{
- struct apr_sms_cleanup *cleanup;
- struct apr_sms_cleanup **cleanup_ref;
- apr_status_t rv = APR_EINVAL;
-
- if (sms->sms_lock)
- apr_lock_acquire(sms->sms_lock);
-
- cleanup = sms->cleanups;
- cleanup_ref = &sms->cleanups;
- sms = sms->accounting;
- while (cleanup) {
- if (type == APR_ALL_CLEANUPS || cleanup->type == type) {
- *cleanup_ref = cleanup->next;
-
- if (sms->free_fn)
- apr_sms_free(sms, cleanup);
-
- cleanup = *cleanup_ref;
- rv = APR_SUCCESS;
- }
- else {
- cleanup_ref = &cleanup->next;
- cleanup = cleanup->next;
- }
- }
-
- if (sms->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 *sms,
- apr_int32_t type,
- const void *data,
- apr_status_t
- (*cleanup_fn)(void *))
-{
- apr_status_t rv;
-
- if ((rv = apr_sms_cleanup_unregister(sms, type,
- data, cleanup_fn)) != APR_SUCCESS)
- return rv;
-
- return cleanup_fn((void*)data);
-}
-
-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;
-
- if (sms->sms_lock)
- apr_lock_acquire(sms->sms_lock);
-
- cleanup = sms->cleanups;
- cleanup_ref = &sms->cleanups;
- sms = sms->accounting;
- while (cleanup) {
- if (type == APR_ALL_CLEANUPS || cleanup->type == type) {
- *cleanup_ref = cleanup->next;
-
- cleanup->cleanup_fn((void*)cleanup->data);
-
- if (sms->free_fn)
- apr_sms_free(sms, cleanup);
-
- cleanup = *cleanup_ref;
- rv = APR_SUCCESS;
- }
- else {
- cleanup_ref = &cleanup->next;
- cleanup = cleanup->next;
- }
- }
-
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- /* The cleanup function should have been registered previously */
- return rv;
-}
-
-#if APR_HAS_THREADS
-APR_DECLARE(apr_status_t) apr_sms_thread_register(apr_sms_t *sms,
- apr_os_thread_t thread)
-{
- apr_status_t rv;
-
- /* Before attempting to acquire a lock for us, we must ensure that our
- * parent is lock-safe.
- */
- if (sms->parent)
- {
- apr_sms_thread_register(sms->parent, thread);
-
- if (!sms->sms_lock) {
- /* Create the sms framework lock we'll use. */
- apr_lock_create(&sms->sms_lock, APR_MUTEX, APR_INTRAPROCESS,
- NULL, sms->parent->pool);
- }
- }
-
- if (sms->sms_lock)
- apr_lock_acquire(sms->sms_lock);
-
- sms->threads++;
-
- /* let the sms know about the thread if it is
- * interested (so it can protect its private
- * data with its own lock)
- *
- * if the sms is doesn't have a thread register
- * function, or it wasn't able to register the
- * thread, we should bomb out!
- * XXX - not sure how to implement the bombing out
- */
- rv = APR_ENOTIMPL;
- if (sms->thread_register_fn)
- rv = sms->thread_register_fn(sms, thread);
-
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- if (rv != APR_SUCCESS)
- return rv;
-
- return APR_SUCCESS;
-}
-
-APR_DECLARE(apr_status_t) apr_sms_thread_unregister(apr_sms_t *sms,
- apr_os_thread_t thread)
-{
- if (sms->sms_lock)
- apr_lock_acquire(sms->sms_lock);
-
- sms->threads--;
-
- /* Even if the thread count hits one, we don't destroy the
- * lock for now
- */
-
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- return APR_SUCCESS;
-}
-#endif /* APR_HAS_THREADS */
-
-APR_DECLARE(const char*) apr_sms_get_identity(apr_sms_t *sms)
-{
- return sms->identity;
-}
-
-APR_DECLARE(apr_sms_t *) apr_sms_get_parent(apr_sms_t *sms)
-{
- return sms->parent;
-}
-
-APR_DECLARE(void) apr_sms_set_abort(apr_abortfunc_t abort, apr_sms_t *sms)
-{
- sms->apr_abort = abort;
-}
-
-APR_DECLARE(apr_abortfunc_t) apr_sms_get_abort(apr_sms_t *sms)
-{
- return sms->apr_abort;
-}
-
-APR_DECLARE(apr_status_t) apr_sms_userdata_set(const void *data,
- const char *key,
- apr_status_t (*cleanup)(void*),
- apr_sms_t *sms)
-{
- apr_size_t keylen = strlen(key);
-
- if (sms->prog_data == NULL)
- sms->prog_data = apr_hash_make(sms->pool);
-
- if (apr_hash_get(sms->prog_data, key, keylen) == NULL) {
- char *new_key = apr_pstrdup(sms->pool, key);
- apr_hash_set(sms->prog_data, new_key, keylen, data);
- } else {
- apr_hash_set(sms->prog_data, key, keylen, data);
- }
-
- apr_sms_cleanup_register(sms, APR_GENERAL_CLEANUP, data, cleanup);
- return APR_SUCCESS;
-}
-
-APR_DECLARE(apr_status_t) apr_sms_userdata_get(void **data, const char *key,
- apr_sms_t *sms)
-{
- if (sms->prog_data == NULL)
- *data = NULL;
- else
- *data = apr_hash_get(sms->prog_data, key, strlen(key));
- return APR_SUCCESS;
-}
-
-#if APR_DEBUG_SHOW_STRUCTURE
-static void add_sms(char *a, char *b, char *c, apr_sms_t *sms,
- apr_sms_t *caller, int sib)
-{
- char tmp[40];
- if (sib == 1) {
- strcat(a, "=");
- strcat(b, " ");
- strcat(c, " ");
- }
- sprintf(tmp, sms == caller ? "**%9p**" : " [%9p] ", sms);
- strcat(a, tmp);
-#if APR_DEBUG_TAG_SMS
- sprintf(tmp, " '%9s' ", sms->tag);
-#else
- sprintf(tmp, " ");
-#endif
- strcat(b, tmp);
- sprintf(tmp, " [%9s] ", sms->identity);
- strcat(c, tmp);
-}
-
-static void add_tab(char *a, char *b, char *c, int level, apr_sms_t *sms)
-{
- char buffer[100];
- int i;
- for(i=0;i < level * 2;i++)
- buffer[i] = ' ';
- buffer[i] = '\0';
- strcpy(a, buffer);
- strcpy(b, buffer);
- strcpy(c, buffer);
- if (sms->parent)
- fprintf(dbg_file, "%s |\n", buffer);
- fflush(dbg_file);
-}
-
-static void print_structure(char *l1, char *l2, char *l3)
-{
- fprintf(dbg_file, "%s\n%s\n%s\n", l1, l2, l3);
- fflush(dbg_file);
-}
-
-static void print_depth(int levels)
-{
- fprintf(dbg_file, "Showing %d level%s of SMS\n", levels + 1,
- levels == 0 ? "" : "s");
-}
-
-APR_DECLARE(void) apr_sms_show_structure(apr_sms_t *sms, int direction)
-{
- apr_sms_t *thesms, *sibling;
- int levels = 0, i = 0;
- char l1[256], l2[256], l3[256];
-
- if (direction == 1) {
- /* we're going up! */
- thesms = sms;
- while (thesms->parent != NULL) {
- levels++;
- thesms = thesms->parent;
- }
- print_depth(levels);
- /* thesms now eqauls the top level... so start showing them! */
- while (thesms) {
- add_tab(l1, l2, l3, i++, thesms);
-
- add_sms(l1, l2, l3, thesms, sms, 0);
-
- sibling = thesms->sibling;
- while (sibling) {
- add_sms(l1, l2, l3, sibling, NULL, 1);
- sibling = sibling->sibling;
- }
- print_structure(l1, l2, l3);
-
- thesms = thesms->child;
- }
- } else {
- /* we go down! i.e. show our descendants */
- thesms = sms;
- while (thesms->child) {
- levels++;
- thesms = thesms->child;
- }
- print_depth(levels);
- thesms = sms;
- while (thesms) {
- add_tab(l1, l2, l3, i++, thesms);
-
- /* add the child... */
- add_sms(l1, l2, l3, thesms, sms, 0);
- /* If we're destroying a sibling, then we won't be destroying
- * the other siblings, just descendants of this SMS, so
- * make sure what we show makes sense!
- */
- if (thesms != sms && thesms->sibling) {
- sibling = thesms->sibling;
- while (sibling) {
- add_sms(l1, l2, l3, sibling, NULL, 1);
- sibling = sibling->sibling;
- }
- }
- print_structure(l1, l2, l3);
- thesms = thesms->child;
- }
- }
-}
-#endif /* APR_DEBUG_SHOW_STRUCTURE */
-
-#if APR_DEBUG_TAG_SMS
-APR_DECLARE(void) apr_sms_tag(apr_sms_t *sms, const char *tag)
-{
- sms->tag = tag;
-}
-#endif
-
diff --git a/memory/unix/apr_sms_blocks.c b/memory/unix/apr_sms_blocks.c
deleted file mode 100644
index e4a1f41c2..000000000
--- a/memory/unix/apr_sms_blocks.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-/* This code kindly donated to APR by
- * Elrond <elrond@samba-tng.org>
- * Luke Kenneth Casson Leighton <lkcl@samba-tng.org>
- * Sander Striker <striker@samba-tng.org>
- *
- * May 2001
- */
-
-#include "apr.h"
-#include "apr_general.h"
-#include "apr_private.h"
-#include "apr_sms.h"
-#include "apr_sms_blocks.h"
-#include "apr_lock.h"
-#include <stdlib.h>
-#include "apr_portable.h"
-#define APR_WANT_MEMFUNC
-#include "apr_want.h"
-#include "sms_private.h"
-
-static const char *module_identity = "BLOCKS";
-#define MIN_ALLOC 8 * 1024 /* don't allocate in smaller blocks than 8Kb */
-
-/*
- * Simple bucket memory system
- */
-
-/* INTERNALLY USED STRUCTURES */
-typedef struct block_t {
- char *nxt;
-} block_t;
-
-typedef struct apr_sms_blocks_t
-{
- apr_sms_t header;
- apr_size_t block_sz;
- apr_size_t alloc_sz;
- block_t *alloc_list;
- block_t *free_list;
- char *ptr;
- char *endp;
- char *self_endp;
-} apr_sms_blocks_t;
-
-/* Various defines we'll use */
-#define SIZEOF_SMS_BLOCKS_T APR_ALIGN_DEFAULT(sizeof(apr_sms_blocks_t))
-#define SIZEOF_BLOCK_T APR_ALIGN_DEFAULT(sizeof(block_t))
-
-#define SMS_BLOCKS_T(sms) ((apr_sms_blocks_t *)sms)
-#define BLOCK_T(mem) ((block_t *)mem)
-
-static void *apr_sms_blocks_malloc(apr_sms_t *sms,
- apr_size_t size)
-{
- void *mem;
-
- if (size > SMS_BLOCKS_T(sms)->block_sz)
- return NULL;
-
- if ((mem = SMS_BLOCKS_T(sms)->free_list) != NULL) {
- SMS_BLOCKS_T(sms)->free_list = BLOCK_T(BLOCK_T(mem)->nxt);
- return mem;
- }
-
- mem = SMS_BLOCKS_T(sms)->ptr;
- if ((SMS_BLOCKS_T(sms)->ptr = (char *)mem + SMS_BLOCKS_T(sms)->block_sz)
- <= SMS_BLOCKS_T(sms)->endp)
- return mem;
-
- /* OK, we've run out of memory. Let's get more :) */
- mem = apr_sms_malloc(sms->parent, SMS_BLOCKS_T(sms)->alloc_sz);
- if (!mem) {
- /* make safe and return */
- SMS_BLOCKS_T(sms)->ptr = SMS_BLOCKS_T(sms)->endp;
- return NULL;
- }
-
- /* Insert our new bit of memory at the start of the list */
- BLOCK_T(mem)->nxt = (char*)SMS_BLOCKS_T(sms)->alloc_list;
- SMS_BLOCKS_T(sms)->alloc_list = mem;
- SMS_BLOCKS_T(sms)->endp = (char *)mem + SMS_BLOCKS_T(sms)->alloc_sz;
- mem = (char *)mem + SIZEOF_BLOCK_T;
- SMS_BLOCKS_T(sms)->ptr = (char *)mem + SMS_BLOCKS_T(sms)->block_sz;
-
- if (SMS_BLOCKS_T(sms)->alloc_list->nxt) {
- /* we're not the first block being added, so we increase our
- * size.
- */
- SMS_BLOCKS_T(sms)->alloc_sz <<= 1;
- }
-
-
- return mem;
-}
-
-static void *apr_sms_blocks_calloc(apr_sms_t *sms,
- apr_size_t size)
-{
- void *mem;
-
- if (size > SMS_BLOCKS_T(sms)->block_sz)
- return NULL;
-
- if ((mem = SMS_BLOCKS_T(sms)->free_list) != NULL) {
- SMS_BLOCKS_T(sms)->free_list = BLOCK_T(BLOCK_T(mem)->nxt);
- memset(mem, '\0', SMS_BLOCKS_T(sms)->block_sz);
- return mem;
- }
-
- mem = SMS_BLOCKS_T(sms)->ptr;
- if ((SMS_BLOCKS_T(sms)->ptr = (char *)mem +
- SMS_BLOCKS_T(sms)->block_sz) <= SMS_BLOCKS_T(sms)->endp) {
- memset(mem, '\0', SMS_BLOCKS_T(sms)->block_sz);
- return mem;
- }
-
- /* probably quicker to just grab malloc memory, then memset as
- * required.
- */
- mem = apr_sms_malloc(sms->parent, SMS_BLOCKS_T(sms)->alloc_sz);
- if (!mem) {
- SMS_BLOCKS_T(sms)->ptr = SMS_BLOCKS_T(sms)->endp;
- return NULL;
- }
-
- /* Insert at the start of the list */
- BLOCK_T(mem)->nxt = (char*)SMS_BLOCKS_T(sms)->alloc_list;
- SMS_BLOCKS_T(sms)->alloc_list = mem;
- SMS_BLOCKS_T(sms)->endp = (char *)mem + SMS_BLOCKS_T(sms)->alloc_sz;
- mem = (char *)mem + SIZEOF_BLOCK_T;
- SMS_BLOCKS_T(sms)->ptr = (char *)mem + SMS_BLOCKS_T(sms)->block_sz;
-
- if (SMS_BLOCKS_T(sms)->alloc_list->nxt) {
- /* we're not the first block being added, so we increase our
- * size.
- */
- SMS_BLOCKS_T(sms)->alloc_sz <<= 1;
- }
-
- memset(mem, '\0', SMS_BLOCKS_T(sms)->block_sz);
-
- return mem;
-}
-
-static apr_status_t apr_sms_blocks_free(apr_sms_t *sms,
- void *mem)
-{
- BLOCK_T(mem)->nxt = (char*)SMS_BLOCKS_T(sms)->free_list;
- SMS_BLOCKS_T(sms)->free_list = mem;
- return APR_SUCCESS;
-}
-
-static apr_status_t apr_sms_blocks_reset(apr_sms_t *sms)
-{
- block_t *block;
-
- SMS_BLOCKS_T(sms)->ptr = (char *)sms + SIZEOF_SMS_BLOCKS_T;
- SMS_BLOCKS_T(sms)->endp = SMS_BLOCKS_T(sms)->self_endp;
- SMS_BLOCKS_T(sms)->free_list = NULL;
-
- while ((block = SMS_BLOCKS_T(sms)->alloc_list) != NULL) {
- SMS_BLOCKS_T(sms)->alloc_list = BLOCK_T(block->nxt);
- apr_sms_free(sms->parent, block);
- }
-
- return APR_SUCCESS;
-}
-
-static apr_status_t apr_sms_blocks_destroy(apr_sms_t *sms)
-{
- block_t *block;
-
- while ((block = SMS_BLOCKS_T(sms)->alloc_list) != NULL) {
- SMS_BLOCKS_T(sms)->alloc_list = BLOCK_T(block->nxt);
- apr_sms_free(sms->parent, block);
- }
-
- return apr_sms_free(sms->parent, sms);
-}
-
-APR_DECLARE(apr_status_t) apr_sms_blocks_create(apr_sms_t **sms,
- apr_sms_t *parent,
- apr_size_t block_size)
-{
- apr_sms_t *new_sms;
- apr_status_t rv;
- apr_size_t alloc_size;
- apr_sms_blocks_t *bms;
-
- *sms = NULL;
- if (block_size == 0)
- return APR_EINVAL;
-
- block_size = APR_ALIGN_DEFAULT(block_size);
- alloc_size = block_size << 2;
- if (alloc_size < MIN_ALLOC)
- alloc_size = MIN_ALLOC;
-
- new_sms = apr_sms_calloc(parent, alloc_size);
-
- if (!new_sms)
- return APR_ENOMEM;
-
- if ((rv = apr_sms_init(new_sms, parent)) != APR_SUCCESS)
- return rv;
-
- new_sms->malloc_fn = apr_sms_blocks_malloc;
- new_sms->calloc_fn = apr_sms_blocks_calloc;
- new_sms->free_fn = apr_sms_blocks_free;
- new_sms->reset_fn = apr_sms_blocks_reset;
- new_sms->destroy_fn = apr_sms_blocks_destroy;
- new_sms->identity = module_identity;
-
- bms = SMS_BLOCKS_T(new_sms);
- bms->block_sz = block_size;
- bms->alloc_sz = alloc_size;
- bms->ptr = (char*)new_sms + SIZEOF_SMS_BLOCKS_T;
- bms->endp = bms->self_endp = (char*)new_sms + alloc_size;
-
- /* We are normally single threaded so no lock */
-
- apr_sms_post_init(new_sms);
-
- *sms = new_sms;
- return APR_SUCCESS;
-}
diff --git a/memory/unix/apr_sms_pools.c b/memory/unix/apr_sms_pools.c
deleted file mode 100644
index f2de23ca9..000000000
--- a/memory/unix/apr_sms_pools.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#include "apr.h"
-#include "apr_pools.h" /* includes apr_sms.h" */
-#include "apr_sms_trivial.h"
-#include "apr_errno.h"
-#include "apr_lock.h"
-#include "apr_portable.h"
-#include "apr_lib.h" /* for apr_vformatter */
-
-#include "sms_private.h"
-
-static int initialized = 0;
-static apr_pool_t *permanent_pool = NULL;
-
-APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool, apr_pool_t *p)
-{
- if (!initialized)
- /* Hmm, if we are given a parent here, is this correct?
- * It should never happen, so we're probably OK....
- */
- return apr_sms_std_create(newpool);
-
- return apr_sms_trivial_create_ex(newpool, p ? p : permanent_pool,
- 0x2000, 0, 0x80000);
-}
-
-APR_DECLARE(void) apr_pool_sub_make(apr_pool_t **p,
- apr_pool_t *pparent,
- apr_abortfunc_t abort)
-{
- if (apr_sms_trivial_create(p, pparent) != APR_SUCCESS)
- return NULL;
-
- apr_sms_set_abort(abort, *p);
-
- return p;
-}
-
-APR_DECLARE(void) apr_pool_cleanup_register(apr_pool_t *pool,
- const void *data,
- apr_status_t (*plain_cleanup)(void*),
- apr_status_t (*child_cleanup)(void*))
-{
- if (plain_cleanup == child_cleanup) {
- /* we only need to register one as an ALL_CLEANUP */
- apr_sms_cleanup_register(pool, APR_ALL_CLEANUPS, data, plain_cleanup);
- return;
- }
- if (plain_cleanup)
- apr_sms_cleanup_register(pool, APR_GENERAL_CLEANUP, data,
- plain_cleanup);
-
- if (child_cleanup)
- apr_sms_cleanup_register(pool, APR_CHILD_CLEANUP, data,
- child_cleanup);
-}
-
-APR_DECLARE(void) apr_pool_cleanup_for_exec(void)
-{
-#if !defined(WIN32) && !defined(OS2)
- /* See note in apr_pools.c for why we do this :) */
- apr_sms_cleanup_run_type(permanent_pool, APR_CHILD_CLEANUP);
-#endif
-}
-
-APR_DECLARE(apr_status_t) apr_pool_alloc_init(apr_pool_t *gp)
-{
- apr_status_t rv;
-
- if ((rv = apr_sms_trivial_create_ex(&permanent_pool, gp,
- 0x2000, 0, 0x80000)) != APR_SUCCESS)
- return rv;
-
- initialized = 1;
-
- return APR_SUCCESS;
-}
-
-APR_DECLARE(void) apr_pool_alloc_term(apr_pool_t *gp)
-{
- if (initialized)
- apr_sms_destroy(permanent_pool);
-
- initialized = 0;
-}
-
-APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b)
-{
- while (b && b != a)
- b = b->parent;
-
- return b == a;
-}
-
-/* This stuff needs to be reviewed, but here it is :) */
-
-struct psprintf_data {
- apr_vformatter_buff_t vbuff;
- char *base;
- apr_sms_t *sms;
-};
-
-static int psprintf_flush(apr_vformatter_buff_t *vbuff)
-{
- struct psprintf_data *ps = (struct psprintf_data*)vbuff;
- apr_size_t size;
- char *ptr;
-
- size = (char*) ps->vbuff.curpos - ps->base;
- ptr = apr_sms_realloc(ps->sms, ps->base, 2*size);
- if (ptr == NULL) {
- fputs("[psprintf_flush] Ouch! Out of memory!\n", stderr);
- exit(1);
- }
- ps->base = ptr;
- ps->vbuff.curpos = ptr + size;
- ps->vbuff.endpos = ptr + 2 * size - 1;
- return 0;
-}
-
-APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *p, const char *fmt, va_list ap)
-{
- struct psprintf_data ps;
- void *ptr;
-
- ps.sms = (apr_sms_t*)p;
- ps.base = apr_sms_malloc(ps.sms, 512);
- if (ps.base == NULL) {
- fputs("[apr_pvsprintf] Ouch! Out of memory!\n", stderr);
- exit(1);
- }
- ps.vbuff.curpos = ps.base;
- ps.vbuff.endpos = ps.base + 511;
- apr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap);
- *ps.vbuff.curpos++ = '\0';
- ptr = ps.base;
- ptr = apr_sms_realloc(ps.sms, ptr, (char*)ps.vbuff.curpos - (char*)ptr);
- if (ptr == NULL) {
- fputs("[apr_pvsprintf #2] Ouch! Out of memory!\n", stderr);
- exit(1);
- }
- return (char*)ptr;
-}
-
-APR_DECLARE_NONSTD(char*) apr_psprintf(apr_pool_t *p, const char *fmt, ...)
-{
- va_list ap;
- char *res;
-
- va_start(ap,fmt);
- res = apr_pvsprintf(p, fmt, ap);
- va_end(ap);
- return res;
-}
-
-APR_DECLARE(void) apr_pool_note_subprocess(apr_pool_t *a, apr_proc_t *pid,
- enum kill_conditions how)
-{
- struct process_chain *newpc = (struct process_chain*)
- apr_sms_malloc(a, sizeof(struct process_chain));
-
- newpc->pid = pid;
- newpc->kill_how = how;
- newpc->next = a -> subprocesses;
- a->subprocesses = newpc;
-}
-
diff --git a/memory/unix/apr_sms_std.c b/memory/unix/apr_sms_std.c
deleted file mode 100644
index 44145c5ae..000000000
--- a/memory/unix/apr_sms_std.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-/* This code kindly donated to APR by
- * Elrond <elrond@samba-tng.org>
- * Luke Kenneth Casson Leighton <lkcl@samba-tng.org>
- * Sander Striker <striker@samba-tng.org>
- *
- * May 2001
- */
-
-#include "apr.h"
-#include "apr_private.h"
-#include "apr_sms.h"
-#include <stdlib.h>
-#include "sms_private.h"
-
-static const char *module_identity = "STANDARD";
-
-/*
- * standard memory system
- */
-
-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 *sms,
- apr_size_t size)
-{
-#if HAVE_CALLOC
- return calloc(1, size);
-#else
- void *mem;
- mem = malloc(size);
- memset(mem, '\0', size);
- return mem;
-#endif
-}
-
-
-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 *sms,
- void *mem)
-{
- free(mem);
- return APR_SUCCESS;
-}
-
-#if APR_HAS_THREADS
-static apr_status_t apr_sms_std_thread_register(apr_sms_t *sms,
- apr_os_thread_t thread)
-{
- return APR_SUCCESS;
-}
-
-static apr_status_t apr_sms_std_thread_unregister(apr_sms_t *sms,
- apr_os_thread_t thread)
-{
- return APR_SUCCESS;
-}
-#endif /* APR_HAS_THREADS */
-
-APR_DECLARE(apr_status_t) apr_sms_std_create(apr_sms_t **sms)
-{
- apr_sms_t *new_sms;
- apr_status_t rv;
-
- *sms = NULL;
- /* We don't have a parent so we allocate the memory
- * for the structure ourselves...
- */
- new_sms = apr_sms_std_calloc(NULL, sizeof(apr_sms_t));
-
- if (!new_sms)
- return APR_ENOMEM;
-
- if ((rv = apr_sms_init(new_sms, NULL)) != APR_SUCCESS)
- return rv;
-
- 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;
-#if APR_HAS_THREADS
- new_sms->thread_register_fn = apr_sms_std_thread_register;
- new_sms->thread_unregister_fn = apr_sms_std_thread_unregister;
-#endif /* APR_HAS_THREADS */
- 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_post_init(new_sms);
-
- *sms = new_sms;
- return APR_SUCCESS;
-}
-
diff --git a/memory/unix/apr_sms_threads.c b/memory/unix/apr_sms_threads.c
deleted file mode 100644
index 359a9a177..000000000
--- a/memory/unix/apr_sms_threads.c
+++ /dev/null
@@ -1,964 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#include "apr.h"
-#include "apr_general.h"
-#include "apr_private.h"
-#include "apr_sms.h"
-#include "apr_sms_threads.h"
-#include "apr_lock.h"
-#include "sms_private.h"
-
-#if APR_HAS_THREADS
-
-static const char *module_identity = "THREADS";
-static const char *module_acct_identity = "THREADS_ACCT";
-
-/*
- * Simple thread memory system
- */
-
-/* INTERNALLY USED STRUCTURES */
-
-typedef struct block_t
-{
- struct node_t *node;
-} block_t;
-
-typedef struct node_t
-{
- struct node_t *next;
- struct node_t *prev;
- char *first_avail;
- apr_size_t avail_size;
- apr_uint16_t count;
-} node_t;
-
-typedef struct thread_node_t
-{
- struct thread_node_t *next;
- struct thread_node_t **ref;
- apr_os_thread_t thread;
- node_t used_sentinel;
- node_t free_sentinel;
- node_t *self;
- apr_size_t max_free;
-} thread_node_t;
-
-/*
- * Primes just below a power of 2:
- * 3, 7, 13, 31, 61, 127, 251, 509, 1021,
- * 2039, 4093, 8191, 16381, 32749, 65521
- */
-
-#define HASH_SIZE 1021
-#define SIZEOF_HASHTABLE APR_ALIGN_DEFAULT(HASH_SIZE)
-#define THREAD_HASH(tid) \
-(*(int *)&(tid) % HASH_SIZE)
-
-typedef struct apr_sms_threads_t
-{
- apr_sms_t sms_hdr;
- node_t used_sentinel;
- node_t free_sentinel;
- node_t *self;
- char *first_avail;
- thread_node_t *hashtable[SIZEOF_HASHTABLE];
- apr_size_t min_free;
- apr_size_t min_alloc;
- apr_size_t max_free;
- apr_size_t thread_max_free;
- apr_lock_t *lock;
-} apr_sms_threads_t;
-
-typedef struct apr_sms_threads_acct_t
-{
- apr_sms_t sms_hdr;
- apr_sms_threads_t *tms;
-} apr_sms_threads_acct_t;
-
-#define SIZEOF_BLOCK_T APR_ALIGN_DEFAULT(sizeof(block_t))
-#define SIZEOF_NODE_T APR_ALIGN_DEFAULT(sizeof(node_t))
-#define SIZEOF_THREAD_NODE_T APR_ALIGN_DEFAULT(sizeof(thread_node_t))
-#define SIZEOF_SMS_THREADS_T APR_ALIGN_DEFAULT(sizeof(apr_sms_threads_t))
-#define SIZEOF_SMS_ACCT_T APR_ALIGN_DEFAULT(sizeof(apr_sms_threads_acct_t))
-
-#define BLOCK_T(mem) ((block_t *)(mem))
-#define NODE_T(mem) ((node_t *)(mem))
-#define THREAD_NODE_T(mem) ((thread_node_t *)(mem))
-#define SMS_THREADS_T(sms) ((apr_sms_threads_t *)(sms))
-#define SMS_ACCT_T(sms) ((apr_sms_threads_acct_t *)(sms))
-
-/* Magic numbers :) */
-
-#define MIN_ALLOC 0x2000
-#define MIN_FREE 0x1000
-#define MAX_FREE 0x100000
-#define THREAD_MAX_FREE 0x80000
-
-static void *apr_sms_threads_malloc(apr_sms_t *sms,
- apr_size_t size)
-{
- thread_node_t *thread_node;
- apr_os_thread_t thread;
- node_t *node, *sentinel;
- apr_size_t node_size;
- apr_uint16_t hash;
- void *mem;
-
- /* Round up the size to the next 8 byte boundary */
- size = APR_ALIGN_DEFAULT(size) + SIZEOF_BLOCK_T;
-
- thread = apr_os_thread_current();
- hash = THREAD_HASH(thread);
-
- /* If the thread wasn't registered before, we will segfault */
- thread_node = SMS_THREADS_T(sms)->hashtable[hash];
- while (!apr_os_thread_equal(thread_node->thread, thread))
- thread_node = thread_node->next;
-
- node = thread_node->used_sentinel.prev;
-
- if (node->avail_size >= size) {
- mem = node->first_avail;
- node->avail_size -= size;
- node->first_avail += size;
- node->count++;
-
- BLOCK_T(mem)->node = node;
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
- }
-
- /* reset the 'last' block, it will be replaced soon */
- node->avail_size += node->first_avail - ((char *)node + SIZEOF_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
-
- /* browse the free list for a useable block */
- sentinel = &thread_node->free_sentinel;
- sentinel->avail_size = size;
-
- node = sentinel->next;
- while (node->avail_size < size)
- node = node->next;
-
- if (node != sentinel) {
- node->prev->next = node->next;
- node->next->prev = node->prev;
-
- sentinel = &thread_node->used_sentinel;
- node->prev = sentinel->prev;
- node->prev->next = node;
- node->next = sentinel;
- sentinel->prev = node;
-
- if (node != thread_node->self)
- thread_node->max_free += node->avail_size;
-
- mem = node->first_avail;
- node->avail_size -= size;
- node->first_avail += size;
- node->count = 1;
-
- BLOCK_T(mem)->node = node;
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
- }
-
- if (SMS_THREADS_T(sms)->lock)
- apr_lock_acquire(SMS_THREADS_T(sms)->lock);
-
- /* browse the shared free list for a useable block */
- sentinel = &SMS_THREADS_T(sms)->free_sentinel;
- sentinel->avail_size = size;
-
- node = sentinel->next;
- while (node->avail_size < size)
- node = node->next;
-
- if (node != sentinel) {
- node->prev->next = node->next;
- node->next->prev = node->prev;
-
- if (SMS_THREADS_T(sms)->lock)
- apr_lock_release(SMS_THREADS_T(sms)->lock);
-
- sentinel = &thread_node->used_sentinel;
- node->prev = sentinel->prev;
- node->prev->next = node;
- node->next = sentinel;
- sentinel->prev = node;
-
- SMS_THREADS_T(sms)->max_free += node->avail_size;
-
- mem = node->first_avail;
- node->avail_size -= size;
- node->first_avail += size;
- node->count = 1;
-
- BLOCK_T(mem)->node = node;
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
- }
-
- if (SMS_THREADS_T(sms)->lock)
- apr_lock_release(SMS_THREADS_T(sms)->lock);
-
- /* we have to allocate a new block from our parent */
- node_size = size + SMS_THREADS_T(sms)->min_free;
- if (node_size < SMS_THREADS_T(sms)->min_alloc)
- node_size = SMS_THREADS_T(sms)->min_alloc;
-
- node = apr_sms_malloc(sms->parent, node_size);
- if (!node) {
- /* restore the 'last' node to prevent the
- * next allocation from segfaulting
- */
- node = thread_node->used_sentinel.prev;
- node->first_avail += node->avail_size;
- node->avail_size = 0;
-
- return NULL;
- }
-
- sentinel = &thread_node->used_sentinel;
- node->prev = sentinel->prev;
- node->prev->next = node;
- node->next = sentinel;
- sentinel->prev = node;
-
- mem = node->first_avail = (char *)node + SIZEOF_NODE_T;
- node->first_avail += size;
- node->avail_size = node_size - (node->first_avail - (char *)node);
- node->count = 1;
-
- BLOCK_T(mem)->node = node;
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
-}
-
-static apr_status_t apr_sms_threads_free(apr_sms_t *sms, void *mem)
-{
- node_t *node, *sentinel;
- thread_node_t *thread_node;
- apr_os_thread_t thread;
- apr_uint16_t hash;
-
- node = BLOCK_T((char *)mem - SIZEOF_BLOCK_T)->node;
-
- node->count--;
- if (node->count)
- return APR_SUCCESS;
-
- thread = apr_os_thread_current();
- hash = THREAD_HASH(thread);
-
- thread_node = SMS_THREADS_T(sms)->hashtable[hash];
- while (!apr_os_thread_equal(thread_node->thread, thread))
- thread_node = thread_node->next;
-
- node->avail_size += node->first_avail -
- ((char *)node + SIZEOF_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
-
- if (thread_node->used_sentinel.prev == node)
- return APR_SUCCESS;
-
- node->next->prev = node->prev;
- node->prev->next = node->next;
-
- if (thread_node->max_free >= node->avail_size ||
- node == thread_node->self) {
- sentinel = &thread_node->free_sentinel;
- node->prev = sentinel->prev;
- node->prev->next = node;
- node->next = sentinel;
- sentinel->prev = node;
-
- if (node != thread_node->self)
- thread_node->max_free -= node->avail_size;
-
- return APR_SUCCESS;
- }
-
- if (sms->parent->free_fn &&
- node->avail_size > SMS_THREADS_T(sms)->max_free)
- return apr_sms_free(sms->parent, node);
-
- if (SMS_THREADS_T(sms)->lock)
- apr_lock_acquire(SMS_THREADS_T(sms)->lock);
-
- sentinel = &SMS_THREADS_T(sms)->free_sentinel;
- node->prev = sentinel->prev;
- node->prev->next = node;
- node->next = sentinel;
- sentinel->prev = node;
-
- SMS_THREADS_T(sms)->max_free -= node->avail_size;
-
- if (SMS_THREADS_T(sms)->lock)
- apr_lock_release(SMS_THREADS_T(sms)->lock);
-
- return APR_SUCCESS;
-}
-
-static apr_status_t apr_sms_threads_thread_register(apr_sms_t *sms,
- apr_os_thread_t thread);
-
-static apr_status_t apr_sms_threads_reset(apr_sms_t *sms)
-{
- node_t *node, *prev, *used_sentinel, *free_sentinel, *free_list;
- thread_node_t *thread_node;
- apr_uint16_t hash;
- apr_size_t min_alloc, max_free;
-
- used_sentinel = &SMS_THREADS_T(sms)->used_sentinel;
- free_sentinel = &SMS_THREADS_T(sms)->free_sentinel;
-
- free_list = NULL;
-
- if (SMS_THREADS_T(sms)->lock)
- apr_lock_acquire(SMS_THREADS_T(sms)->lock);
-
- /* Actually, the thread creation function should have installed
- * a cleanup which effectively kills all the threads created using
- * this sms. Therefor it is not wise to call reset from another
- * thread than the 'master' thread.
- */
- for (hash = 0; hash < HASH_SIZE; hash++) {
- while ((thread_node = SMS_THREADS_T(sms)->hashtable[hash]) != NULL) {
- if ((*thread_node->ref = thread_node->next) != NULL)
- thread_node->next->ref = thread_node->ref;
-
- node = thread_node->self;
- node->prev->next = node->next;
- node->next->prev = node->prev;
- node->avail_size += node->first_avail -
- ((char *)node + SIZEOF_NODE_T);
-
- node = thread_node->used_sentinel.prev;
- node->avail_size += node->first_avail -
- ((char *)node + SIZEOF_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
- node->next = thread_node->free_sentinel.next;
- node->next->prev = node;
-
- node = thread_node->free_sentinel.prev;
- node->next = used_sentinel->next;
- node->next->prev = node;
-
- used_sentinel->next = thread_node->used_sentinel.next;
- used_sentinel->next->prev = used_sentinel;
-
- node = NODE_T(thread_node);
- node->avail_size = thread_node->self->avail_size +
- SIZEOF_THREAD_NODE_T;
- node->first_avail = (char *)node + SIZEOF_NODE_T;
-
- node->next = used_sentinel->next;
- node->next->prev = node;
- used_sentinel->next = node;
- node->prev = used_sentinel;
- }
- }
-
- node = SMS_THREADS_T(sms)->self;
- node->avail_size += node->first_avail - ((char *)node + SIZEOF_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
- node->count = 0;
- node->prev->next = node->next;
- node->next->prev = node->prev;
-
- node = used_sentinel->prev;
- node->avail_size += node->first_avail - ((char *)node + SIZEOF_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
-
- if (sms->parent->free_fn) {
- min_alloc = SMS_THREADS_T(sms)->min_alloc;
- max_free = SMS_THREADS_T(sms)->max_free;
- used_sentinel->avail_size = min_alloc;
- while (max_free > min_alloc) {
- if (node->avail_size <= max_free) {
- if (node == used_sentinel)
- break;
-
- max_free -= node->avail_size;
- node->prev->next = node->next;
- node->next->prev = node->prev;
-
- prev = node->prev;
-
- node->next = free_sentinel->next;
- free_sentinel->next = node;
- node->next->prev = node;
- node->prev = free_sentinel;
-
- node = prev;
- }
- else
- node = node->prev;
- }
- SMS_THREADS_T(sms)->max_free = max_free;
-
- used_sentinel->prev->next = NULL;
- free_list = used_sentinel->next;
- }
- else {
- node = used_sentinel->prev;
- node->next = free_sentinel->next;
- node->next->prev = node;
-
- node = used_sentinel->next;
- node->prev = free_sentinel;
- free_sentinel->next = node;
- }
-
- node = SMS_THREADS_T(sms)->self;
- node->next = node->prev = used_sentinel;
- used_sentinel->next = used_sentinel->prev = node;
-
- sms->accounting = (apr_sms_t *)((char *)sms + SIZEOF_SMS_THREADS_T);
-
- apr_sms_threads_thread_register(sms, apr_os_thread_current());
-
- if (SMS_THREADS_T(sms)->lock)
- apr_lock_release(SMS_THREADS_T(sms)->lock);
-
- while ((node = free_list) != NULL) {
- free_list = node->next;
- apr_sms_free(sms->parent, node);
- }
-
- return APR_SUCCESS;
-}
-
-static apr_status_t apr_sms_threads_pre_destroy(apr_sms_t *sms)
-{
- /* This function WILL always be called. However, be aware that the
- * main sms destroy function knows that it's not wise to try and destroy
- * the same piece of memory twice, so the destroy function in a child won't
- * necessarily be called. To guarantee we destroy the lock it's therefore
- * destroyed here.
- */
-
- if (SMS_THREADS_T(sms)->lock) {
- apr_lock_acquire(SMS_THREADS_T(sms)->lock);
- apr_lock_destroy(SMS_THREADS_T(sms)->lock);
- SMS_THREADS_T(sms)->lock = NULL;
- }
-
- return APR_SUCCESS;
-}
-
-static apr_status_t apr_sms_threads_destroy(apr_sms_t *sms)
-{
- node_t *node, *next, *used_sentinel, *free_sentinel;
- thread_node_t *thread_node;
- apr_uint16_t hash;
-
- for (hash = 0; hash < HASH_SIZE; hash++) {
- while ((thread_node = SMS_THREADS_T(sms)->hashtable[hash]) != NULL) {
- if ((*thread_node->ref = thread_node->next) != NULL)
- thread_node->next->ref = thread_node->ref;
-
- node = thread_node->self;
- node->prev->next = node->next;
- node->next->prev = node->prev;
-
- used_sentinel = &thread_node->used_sentinel;
- free_sentinel = &thread_node->free_sentinel;
-
- free_sentinel->prev->next = NULL;
- used_sentinel->prev->next = free_sentinel->next;
-
- node = used_sentinel->next;
- while (node) {
- next = node->next;
- apr_sms_free(sms->parent, node);
- node = next;
- }
-
- apr_sms_free(sms->parent, thread_node);
- }
- }
-
- node = SMS_THREADS_T(sms)->self;
- node->prev->next = node->next;
- node->next->prev = node->prev;
-
- used_sentinel = &SMS_THREADS_T(sms)->used_sentinel;
- free_sentinel = &SMS_THREADS_T(sms)->free_sentinel;
-
- free_sentinel->prev->next = NULL;
- used_sentinel->prev->next = free_sentinel->next;
-
- node = used_sentinel->next;
- while (node) {
- next = node->next;
- apr_sms_free(sms->parent, node);
- node = next;
- }
-
- return apr_sms_free(sms->parent, sms);
-}
-
-static apr_status_t apr_sms_threads_thread_register(apr_sms_t *sms,
- apr_os_thread_t thread)
-{
- thread_node_t *thread_node;
- node_t *node, *sentinel;
- apr_uint16_t hash;
-
- hash = THREAD_HASH(thread);
-
- if (sms->threads > 1 && !SMS_THREADS_T(sms)->lock) {
- apr_lock_create(&SMS_THREADS_T(sms)->lock,
- APR_MUTEX, APR_LOCKALL,
- NULL, sms->pool);
- }
-
- if (SMS_THREADS_T(sms)->lock)
- apr_lock_acquire(SMS_THREADS_T(sms)->lock);
-
- sentinel = &SMS_THREADS_T(sms)->free_sentinel;
- if ((node = sentinel->next) != sentinel) {
- node->prev->next = node->next;
- node->next->prev = node->prev;
-
- thread_node = THREAD_NODE_T(node);
- node = NODE_T((char *)thread_node + SIZEOF_THREAD_NODE_T);
- node->avail_size = NODE_T(thread_node)->avail_size -
- SIZEOF_THREAD_NODE_T;
- node->first_avail = (char *)node + SIZEOF_NODE_T;
- }
- else {
- thread_node = apr_sms_malloc(sms->parent, SMS_THREADS_T(sms)->min_alloc);
- if (!thread_node) {
- if (SMS_THREADS_T(sms)->lock)
- apr_lock_release(SMS_THREADS_T(sms)->lock);
-
- return APR_ENOMEM;
- }
-
- node = NODE_T((char *)thread_node + SIZEOF_THREAD_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
- node->avail_size = SMS_THREADS_T(sms)->min_alloc -
- (node->first_avail - (char *)thread_node);
- }
- node->count = 0;
-
- thread_node->self = node;
- thread_node->max_free = SMS_THREADS_T(sms)->thread_max_free;
-
- sentinel = &thread_node->used_sentinel;
- node->prev = node->next = sentinel;
- sentinel->prev = sentinel->next = node;
-
- sentinel = &thread_node->free_sentinel;
- sentinel->prev = sentinel->next = sentinel;
-
- thread_node->thread = thread;
- if ((thread_node->next = SMS_THREADS_T(sms)->hashtable[hash]) != NULL)
- thread_node->next->ref = &thread_node->next;
- thread_node->ref = &SMS_THREADS_T(sms)->hashtable[hash];
- SMS_THREADS_T(sms)->hashtable[hash] = thread_node;
-
- if (SMS_THREADS_T(sms)->lock)
- apr_lock_release(SMS_THREADS_T(sms)->lock);
-
- return APR_SUCCESS;
-}
-
-static apr_status_t apr_sms_threads_thread_unregister(apr_sms_t *sms,
- apr_os_thread_t thread)
-{
- thread_node_t *thread_node;
- node_t *node, *prev, *free_list, *used_sentinel, *free_sentinel;
- apr_uint16_t hash;
- apr_size_t min_alloc, max_free;
-
- hash = THREAD_HASH(thread);
- free_list = NULL;
-
- if (SMS_THREADS_T(sms)->lock)
- apr_lock_acquire(SMS_THREADS_T(sms)->lock);
-
- thread_node = SMS_THREADS_T(sms)->hashtable[hash];
- while (!apr_os_thread_equal(thread_node->thread, thread))
- thread_node = thread_node->next;
-
- if ((*thread_node->ref = thread_node->next) != NULL)
- thread_node->next->ref = thread_node->ref;
-
- node = thread_node->self;
- node->avail_size += node->first_avail - ((char *)node + SIZEOF_NODE_T);
- node->prev->next = node->next;
- node->next->prev = node->prev;
-
- used_sentinel = &thread_node->used_sentinel;
- free_sentinel = &SMS_THREADS_T(sms)->free_sentinel;
-
- node = used_sentinel->prev;
- node->avail_size += node->first_avail - ((char *)node + SIZEOF_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
-
- node->next = thread_node->free_sentinel.next;
- node->next->prev = node;
-
- node = thread_node->free_sentinel.prev;
- node->next = used_sentinel;
- used_sentinel->prev = node;
-
- min_alloc = SMS_THREADS_T(sms)->min_alloc;
- max_free = SMS_THREADS_T(sms)->max_free;
- used_sentinel->avail_size = min_alloc;
- while (max_free > min_alloc) {
- if (node->avail_size <= max_free) {
- if (node == used_sentinel)
- break;
-
- max_free -= node->avail_size;
- node->prev->next = node->next;
- node->next->prev = node->prev;
- prev = node->prev;
-
- node->next = free_sentinel->next;
- free_sentinel->next = node;
- node->next->prev = node;
- node->prev = free_sentinel;
-
- node = prev;
- }
- else
- node = node->prev;
- }
-
- used_sentinel->prev->next = NULL;
- free_list = used_sentinel->next;
-
- node = NODE_T(thread_node);
- node->avail_size = thread_node->self->avail_size +
- SIZEOF_THREAD_NODE_T;
- node->first_avail = (char *)node + SIZEOF_NODE_T;
-
- if (max_free >= node->avail_size) {
- max_free -= node->avail_size;
-
- node->next = free_sentinel->next;
- node->next->prev = node;
- free_sentinel->next = node;
- node->prev = free_sentinel;
- }
- else {
- node->next = free_list;
- free_list = node;
- }
-
- SMS_THREADS_T(sms)->max_free = max_free;
-
- if (SMS_THREADS_T(sms)->lock)
- apr_lock_release(SMS_THREADS_T(sms)->lock);
-
- while ((node = free_list) != NULL) {
- free_list = node->next;
- apr_sms_free(sms->parent, node);
- }
-
- return APR_SUCCESS;
-}
-
-static void *apr_sms_threads_acct_malloc(apr_sms_t *sms, apr_size_t size)
-{
- apr_sms_threads_t *tms;
- node_t *node, *sentinel;
- apr_size_t node_size;
- void *mem;
-
- tms = SMS_ACCT_T(sms)->tms;
-
- /* Round up the size to the next 8 byte boundary */
- size = APR_ALIGN_DEFAULT(size) + SIZEOF_BLOCK_T;
-
- if (tms->lock)
- apr_lock_acquire(tms->lock);
-
- node = tms->used_sentinel.prev;
-
- if (node->avail_size >= size) {
- mem = node->first_avail;
- node->avail_size -= size;
- node->first_avail += size;
- node->count++;
-
- if (tms->lock)
- apr_lock_release(tms->lock);
-
- BLOCK_T(mem)->node = node;
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
- }
-
- /* reset the 'last' block, it will be replaced soon */
- node->avail_size += node->first_avail - ((char *)node + SIZEOF_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
-
- /* browse the free list for a useable block */
- sentinel = &tms->free_sentinel;
- sentinel->avail_size = size;
-
- node = sentinel->next;
- while (node->avail_size < size)
- node = node->next;
-
- if (node != sentinel) {
- node->prev->next = node->next;
- node->next->prev = node->prev;
-
- sentinel = &tms->used_sentinel;
- node->prev = sentinel->prev;
- node->prev->next = node;
- node->next = sentinel;
- sentinel->prev = node;
-
- if (node != tms->self)
- tms->max_free += node->avail_size;
-
- mem = node->first_avail;
- node->avail_size -= size;
- node->first_avail += size;
- node->count = 1;
-
- if (tms->lock)
- apr_lock_release(tms->lock);
-
- BLOCK_T(mem)->node = node;
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
- }
-
- /* we have to allocate a new block from our parent */
- node_size = size + tms->min_free;
- if (node_size < tms->min_alloc)
- node_size = tms->min_alloc;
-
- node = apr_sms_malloc(sms->parent, node_size);
- if (!node) {
- /* restore the 'last' node, so the next allocation
- * will not segfault
- */
- node = tms->used_sentinel.prev;
- node->first_avail += node->avail_size;
- node->avail_size = 0;
-
- if (tms->lock)
- apr_lock_release(tms->lock);
-
- return NULL;
- }
-
- sentinel = &tms->used_sentinel;
- node->prev = sentinel->prev;
- node->prev->next = node;
- node->next = sentinel;
- sentinel->prev = node;
-
- mem = node->first_avail = (char *)node + SIZEOF_NODE_T;
- node->first_avail += size;
- node->avail_size = node_size - (node->first_avail - (char *)node);
- node->count = 1;
-
- if (tms->lock)
- apr_lock_release(tms->lock);
-
- BLOCK_T(mem)->node = node;
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
-}
-
-static apr_status_t apr_sms_threads_acct_free(apr_sms_t *sms, void *mem)
-{
- apr_sms_threads_t *tms;
- node_t *node, *sentinel;
-
- tms = SMS_ACCT_T(sms)->tms;
- node = BLOCK_T((char *)mem - SIZEOF_BLOCK_T)->node;
-
- if (tms->lock)
- apr_lock_acquire(tms->lock);
-
- node->count--;
-
- if (node->count) {
- if (tms->lock)
- apr_lock_release(tms->lock);
-
- return APR_SUCCESS;
- }
-
- node->avail_size += node->first_avail - ((char *)node + SIZEOF_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
-
- if (tms->used_sentinel.prev != node) {
- node->next->prev = node->prev;
- node->prev->next = node->next;
-
- if (sms->parent->free_fn &&
- node->avail_size > tms->max_free &&
- node != tms->self) {
- if (tms->lock)
- apr_lock_release(tms->lock);
-
- return apr_sms_free(sms->parent, node);
- }
-
- sentinel = &tms->free_sentinel;
- node->prev = sentinel->prev;
- node->prev->next = node;
- node->next = sentinel;
- sentinel->prev = node;
-
- if (node != tms->self)
- tms->max_free -= node->avail_size;
- }
-
- if (tms->lock)
- apr_lock_release(tms->lock);
-
- return APR_SUCCESS;
-}
-
-APR_DECLARE(apr_status_t) apr_sms_threads_create(apr_sms_t **sms,
- apr_sms_t *pms)
-{
- return apr_sms_threads_create_ex(sms, pms, MIN_ALLOC, MIN_FREE, MAX_FREE);
-}
-
-APR_DECLARE(apr_status_t) apr_sms_threads_create_ex(apr_sms_t **sms,
- apr_sms_t *pms,
- apr_size_t min_alloc,
- apr_size_t min_free,
- apr_size_t max_free)
-{
- apr_sms_t *new_sms, *ams;
- apr_sms_threads_t *tms;
- node_t *node;
- apr_status_t rv;
-
- *sms = NULL;
-
- min_alloc = APR_ALIGN_DEFAULT(min_alloc);
- min_free = APR_ALIGN_DEFAULT(min_free);
-
- /* 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...
- */
- new_sms = apr_sms_calloc(pms, min_alloc);
- if (!new_sms)
- return APR_ENOMEM;
-
- if ((rv = apr_sms_init(new_sms, pms)) != APR_SUCCESS)
- return rv;
-
- new_sms->malloc_fn = apr_sms_threads_malloc;
- new_sms->free_fn = apr_sms_threads_free;
- new_sms->reset_fn = apr_sms_threads_reset;
- new_sms->pre_destroy_fn = apr_sms_threads_pre_destroy;
- new_sms->destroy_fn = apr_sms_threads_destroy;
- new_sms->thread_register_fn = apr_sms_threads_thread_register;
- new_sms->thread_unregister_fn = apr_sms_threads_thread_unregister;
- new_sms->identity = module_identity;
-
- ams = (apr_sms_t *)((char *)new_sms + SIZEOF_SMS_THREADS_T);
-
- node = NODE_T((char *)ams + SIZEOF_SMS_ACCT_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
- node->avail_size = min_alloc - (node->first_avail - (char *)new_sms);
- node->count = 0;
-
- tms = SMS_THREADS_T(new_sms);
- tms->min_alloc = min_alloc;
- tms->min_free = min_free;
- tms->max_free = max_free;
- tms->thread_max_free = THREAD_MAX_FREE;
- tms->self = node;
-
- node->next = node->prev = &tms->used_sentinel;
- tms->used_sentinel.next = tms->used_sentinel.prev = node;
- tms->free_sentinel.next = tms->free_sentinel.prev = &tms->free_sentinel;
-
- apr_sms_init(ams, new_sms);
- ams->malloc_fn = apr_sms_threads_acct_malloc;
- ams->free_fn = apr_sms_threads_acct_free;
- ams->identity = module_acct_identity;
- SMS_ACCT_T(ams)->tms = tms;
- apr_sms_post_init(ams);
-
- new_sms->accounting = ams;
-
- apr_sms_post_init(new_sms);
-
- *sms = new_sms;
- return APR_SUCCESS;
-}
-
-#endif /* APR_HAS_THREADS */
-
diff --git a/memory/unix/apr_sms_tracking.c b/memory/unix/apr_sms_tracking.c
deleted file mode 100644
index 64ecbfbc4..000000000
--- a/memory/unix/apr_sms_tracking.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-/* This code kindly donated to APR by
- * Elrond <elrond@samba-tng.org>
- * Luke Kenneth Casson Leighton <lkcl@samba-tng.org>
- * Sander Striker <striker@samba-tng.org>
- *
- * May 2001
- */
-
-#include "apr.h"
-#include "apr_general.h"
-#include "apr_private.h"
-#include "apr_sms.h"
-#include "apr_sms_tracking.h"
-#include "apr_lock.h"
-#include <stddef.h> /* for NULL */
-#include "sms_private.h"
-
-static const char *module_identity = "TRACKING";
-
-/*
- * Simple tracking memory system
- */
-
-/* INTERNALLY USED STRUCTURES */
-typedef struct block_t
-{
- struct block_t *next;
- struct block_t **ref;
-} block_t;
-
-typedef struct apr_sms_tracking_t
-{
- apr_sms_t sms_hdr;
- block_t *blocks;
- apr_lock_t *lock;
-} apr_sms_tracking_t;
-
-#define SIZEOF_BLOCK_T APR_ALIGN_DEFAULT(sizeof(block_t))
-#define SIZEOF_SMS_TRACKING_T APR_ALIGN_DEFAULT(sizeof(apr_sms_tracking_t))
-
-#define BLOCK_T(mem) ((block_t *)(mem))
-#define SMS_TRACKING_T(sms) ((apr_sms_tracking_t *)(sms))
-
-#define INSERT_BLOCK(block, tms) \
- if (tms->lock) \
- apr_lock_acquire(tms->lock); \
- \
- block->ref = &tms->blocks; \
- if ((block->next = tms->blocks) != NULL) \
- block->next->ref = &block->next; \
- tms->blocks = block; \
- \
- if (tms->lock) \
- apr_lock_release(tms->lock);
-
-#define REMOVE_BLOCK(block, tms) \
- if (tms->lock) \
- apr_lock_acquire(tms->lock); \
- \
- *block->ref = block->next; \
- if ((*block->ref = block->next) != NULL) \
- block->next->ref = block->ref; \
- \
- if (tms->lock) \
- apr_lock_release(tms->lock);
-
-static void *apr_sms_tracking_malloc(apr_sms_t *sms,
- apr_size_t size)
-{
- void *mem;
-
- size = APR_ALIGN_DEFAULT(size) + SIZEOF_BLOCK_T;
- mem = apr_sms_malloc(sms->parent, size);
- if (!mem)
- return NULL;
-
- INSERT_BLOCK(BLOCK_T(mem), SMS_TRACKING_T(sms))
-
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
-}
-
-static void *apr_sms_tracking_calloc(apr_sms_t *sms,
- apr_size_t size)
-{
- void *mem;
-
- size = APR_ALIGN_DEFAULT(size) + SIZEOF_BLOCK_T;
- mem = apr_sms_calloc(sms->parent, size);
- if (!mem)
- return NULL;
-
- INSERT_BLOCK(BLOCK_T(mem), SMS_TRACKING_T(sms))
-
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
-}
-
-static void *apr_sms_tracking_realloc(apr_sms_t *sms,
- void *mem, apr_size_t size)
-{
- block_t *block;
-
- block = BLOCK_T((char *)mem - SIZEOF_BLOCK_T);
-
- REMOVE_BLOCK(block, SMS_TRACKING_T(sms))
-
- size = APR_ALIGN_DEFAULT(size) + SIZEOF_BLOCK_T;
- mem = apr_sms_realloc(sms->parent, block, size);
- if (!mem)
- return NULL;
-
- INSERT_BLOCK(BLOCK_T(mem), SMS_TRACKING_T(sms))
-
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
-}
-
-static apr_status_t apr_sms_tracking_free(apr_sms_t *sms,
- void *mem)
-{
- mem = (char *)mem - SIZEOF_BLOCK_T;
-
- REMOVE_BLOCK(BLOCK_T(mem), SMS_TRACKING_T(sms));
-
- return apr_sms_free(sms->parent, mem);
-}
-
-static apr_status_t apr_sms_tracking_reset(apr_sms_t *sms)
-{
- block_t *block;
- apr_status_t rv = APR_SUCCESS;
-
- if (SMS_TRACKING_T(sms)->lock)
- apr_lock_acquire(SMS_TRACKING_T(sms)->lock);
-
- while ((block = SMS_TRACKING_T(sms)->blocks) != NULL) {
- if ((*block->ref = block->next) != NULL)
- block->next->ref = block->ref;
-
- if ((rv = apr_sms_free(sms->parent, block)) != APR_SUCCESS)
- break;
- }
-
- if (SMS_TRACKING_T(sms)->lock)
- apr_lock_release(SMS_TRACKING_T(sms)->lock);
-
- return rv;
-}
-
-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
- * the same piece of memory twice, so the destroy function in a child won't
- * necessarily be called. To guarantee we destroy the lock it's therefore
- * destroyed here.
- */
-
- if (SMS_TRACKING_T(sms)->lock) {
- apr_lock_acquire(SMS_TRACKING_T(sms)->lock);
- apr_lock_destroy(SMS_TRACKING_T(sms)->lock);
- SMS_TRACKING_T(sms)->lock = NULL;
- }
-
- return APR_SUCCESS;
-}
-
-static apr_status_t apr_sms_tracking_destroy(apr_sms_t *sms)
-{
- apr_status_t rv;
-
- if ((rv = apr_sms_reset(sms)) != APR_SUCCESS)
- return rv;
-
- return apr_sms_free(sms->parent, sms);
-}
-
-#if APR_HAS_THREADS
-static apr_status_t apr_sms_tracking_thread_register(apr_sms_t *sms,
- apr_os_thread_t thread)
-{
- if (!SMS_TRACKING_T(sms)->lock && sms->threads > 1)
- return apr_lock_create(&SMS_TRACKING_T(sms)->lock,
- APR_MUTEX, APR_LOCKALL,
- NULL, sms->pool);
- return APR_SUCCESS;
-}
-
-static apr_status_t apr_sms_tracking_thread_unregister(apr_sms_t *sms,
- apr_os_thread_t thread)
-{
- return APR_SUCCESS;
-}
-#endif /* APR_HAS_THREADS */
-
-
-APR_DECLARE(apr_status_t) apr_sms_tracking_create(apr_sms_t **sms,
- apr_sms_t *pms)
-{
- apr_sms_t *new_sms;
- apr_status_t rv;
-
- *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...
- */
- new_sms = apr_sms_calloc(pms, SIZEOF_SMS_TRACKING_T);
-
- if (!new_sms)
- return APR_ENOMEM;
-
- if ((rv = apr_sms_init(new_sms, pms)) != APR_SUCCESS)
- return rv;
-
- new_sms->malloc_fn = apr_sms_tracking_malloc;
- new_sms->calloc_fn = apr_sms_tracking_calloc;
- new_sms->realloc_fn = apr_sms_tracking_realloc;
- new_sms->free_fn = apr_sms_tracking_free;
- new_sms->reset_fn = apr_sms_tracking_reset;
- new_sms->pre_destroy_fn = apr_sms_tracking_pre_destroy;
- new_sms->destroy_fn = apr_sms_tracking_destroy;
-#if APR_HAS_THREADS
- new_sms->thread_register_fn = apr_sms_tracking_thread_register;
- new_sms->thread_unregister_fn = apr_sms_tracking_thread_unregister;
-#endif /* APR_HAS_THREADS */
- new_sms->identity = module_identity;
-
- apr_sms_post_init(new_sms);
-
- *sms = new_sms;
- return APR_SUCCESS;
-}
diff --git a/memory/unix/apr_sms_trivial.c b/memory/unix/apr_sms_trivial.c
deleted file mode 100644
index 800b219f7..000000000
--- a/memory/unix/apr_sms_trivial.c
+++ /dev/null
@@ -1,531 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#include "apr.h"
-#include "apr_general.h"
-#include "apr_private.h"
-#include "apr_sms.h"
-#include "apr_sms_trivial.h"
-#include "apr_lock.h"
-#define APR_WANT_MEMFUNC
-#include "apr_want.h"
-#include "sms_private.h"
-#include <stddef.h>
-
-static const char *module_identity = "TRIVIAL";
-
-/*
- * Simple trivial memory system
- *
- * The goal of this SMS is to make malloc and reset operations as efficient
- * as possible.
- */
-
-/* INTERNALLY USED STRUCTURES */
-
-typedef struct block_t
-{
- struct node_t *node;
-} block_t;
-
-typedef struct node_t
-{
- struct node_t *next;
- struct node_t *prev;
- char *first_avail;
- apr_size_t avail_size;
- apr_uint32_t count;
-} node_t;
-
-typedef struct apr_sms_trivial_t
-{
- apr_sms_t sms_hdr;
- node_t used_sentinel;
- node_t free_sentinel;
- node_t *self;
- apr_size_t min_alloc;
- apr_size_t min_free;
- apr_size_t max_free;
-} apr_sms_trivial_t;
-
-#define SIZEOF_BLOCK_T APR_ALIGN_DEFAULT(sizeof(block_t))
-#define SIZEOF_NODE_T APR_ALIGN_DEFAULT(sizeof(node_t))
-#define SIZEOF_SMS_TRIVIAL_T APR_ALIGN_DEFAULT(sizeof(apr_sms_trivial_t))
-
-#define BLOCK_T(mem) ((block_t *)(mem))
-#define NODE_T(mem) ((node_t *)(mem))
-#define SMS_TRIVIAL_T(sms) ((apr_sms_trivial_t *)(sms))
-
-/* Magic numbers :)
- * MIN_ALLOC defines the floor of how many bytes we will ask our parent for
- * MIN_FREE defines how many extra bytes we will allocate when asking the
- * the system for memory.
- * MAX_FREE defines how many bytes the SMS may hold at one time. If it
- * exceeds this value, it will return memory to the parent SMS.
- * (note that this implementation counts down to 0)
- */
-#define MIN_ALLOC 0x2000
-#define MIN_FREE 0x1000
-#define MAX_FREE 0x80000
-
-static void *apr_sms_trivial_malloc(apr_sms_t *sms,
- apr_size_t size)
-{
- node_t *node, *sentinel;
- apr_size_t node_size;
- void *mem;
-
- /* Round up the size to the next 8 byte boundary */
- size = APR_ALIGN_DEFAULT(size) + SIZEOF_BLOCK_T;
-
- if (sms->sms_lock)
- apr_lock_acquire(sms->sms_lock);
-
- node = SMS_TRIVIAL_T(sms)->used_sentinel.prev;
-
- if (node->avail_size >= size) {
- mem = node->first_avail;
- node->avail_size -= size;
- node->first_avail += size;
- node->count++;
-
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- BLOCK_T(mem)->node = node;
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
- }
-
- /* reset the 'last' block, it will be replaced soon */
- node->avail_size += node->first_avail - ((char *)node + SIZEOF_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
-
- /* browse the free list for a useable block. Note that we set the
- * sentinel to be the size we are looking for - so, we'll have to
- * stop when we hit the sentinel again.
- */
- sentinel = &SMS_TRIVIAL_T(sms)->free_sentinel;
- sentinel->avail_size = size;
-
- node = sentinel->next;
- while (node->avail_size < size)
- node = node->next;
-
- if (node != sentinel) {
- /* Remove from chain of free nodes and add it to used chain */
- node->prev->next = node->next;
- node->next->prev = node->prev;
-
- sentinel = &SMS_TRIVIAL_T(sms)->used_sentinel;
- node->prev = sentinel->prev;
- node->prev->next = node;
- node->next = sentinel;
- sentinel->prev = node;
-
- /* We are no longer free, so increase available free mem. */
- if (node != SMS_TRIVIAL_T(sms)->self)
- SMS_TRIVIAL_T(sms)->max_free += node->avail_size;
-
- mem = node->first_avail;
- node->avail_size -= size;
- node->first_avail += size;
- node->count = 1;
-
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- BLOCK_T(mem)->node = node;
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
- }
-
- /* We couldn't find any used or free node that had enough space,
- * so we have to allocate a new block from our parent.
- */
- node_size = size + SMS_TRIVIAL_T(sms)->min_free;
- if (node_size < SMS_TRIVIAL_T(sms)->min_alloc)
- node_size = SMS_TRIVIAL_T(sms)->min_alloc;
-
- node = apr_sms_malloc(sms->parent, node_size);
- if (!node) {
- /* restore the 'last' node, so next allocation will not segfault */
- node = SMS_TRIVIAL_T(sms)->used_sentinel.prev;
- node->first_avail += node->avail_size;
- node->avail_size = 0;
-
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- return NULL;
- }
-
- /* Add the new node to the used chain. */
- sentinel = &SMS_TRIVIAL_T(sms)->used_sentinel;
- node->prev = sentinel->prev;
- node->prev->next = node;
- node->next = sentinel;
- sentinel->prev = node;
-
- mem = node->first_avail = (char *)node + SIZEOF_NODE_T;
- node->first_avail += size;
- node->avail_size = node_size - (node->first_avail - (char *)node);
- node->count = 1;
-
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- BLOCK_T(mem)->node = node;
- mem = (char *)mem + SIZEOF_BLOCK_T;
-
- return mem;
-}
-
-static apr_status_t apr_sms_trivial_free(apr_sms_t *sms, void *mem)
-{
- node_t *node, *sentinel;
-
- node = BLOCK_T((char *)mem - SIZEOF_BLOCK_T)->node;
-
- if (sms->sms_lock)
- apr_lock_acquire(sms->sms_lock);
-
- node->count--;
-
- if (node->count) {
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- return APR_SUCCESS;
- }
-
- node->avail_size += node->first_avail - ((char *)node + SIZEOF_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
-
- if (SMS_TRIVIAL_T(sms)->used_sentinel.prev != node) {
- node->next->prev = node->prev;
- node->prev->next = node->next;
-
- if (sms->parent->free_fn &&
- node->avail_size > SMS_TRIVIAL_T(sms)->max_free &&
- node != SMS_TRIVIAL_T(sms)->self) {
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- return apr_sms_free(sms->parent, node);
- }
-
- sentinel = &SMS_TRIVIAL_T(sms)->free_sentinel;
- node->prev = sentinel->prev;
- node->prev->next = node;
- node->next = sentinel;
- sentinel->prev = node;
-
- if (node != SMS_TRIVIAL_T(sms)->self)
- SMS_TRIVIAL_T(sms)->max_free -= node->avail_size;
- }
-
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- return APR_SUCCESS;
-}
-
-static void *apr_sms_trivial_realloc(apr_sms_t *sms, void *mem, apr_size_t reqsize)
-{
- void *new_mem;
- apr_size_t size;
- node_t *node;
- char *endp;
-
- reqsize = APR_ALIGN_DEFAULT(reqsize);
-
- new_mem = apr_sms_trivial_malloc(sms, reqsize);
-
- if (new_mem) {
- node = BLOCK_T((char *)mem - SIZEOF_BLOCK_T)->node;
-
- endp = node->first_avail;
- if (endp == (char *)node + SIZEOF_NODE_T)
- endp += node->avail_size;
-
- size = endp - (char *)mem;
- if (size > reqsize)
- size = reqsize;
-
- memcpy(new_mem, mem, size);
- }
-
- apr_sms_trivial_free(sms, mem);
-
- return new_mem;
-}
-
-static apr_status_t apr_sms_trivial_reset(apr_sms_t *sms)
-{
- node_t *node, *prev, *used_sentinel, *free_sentinel, *free_list;
- apr_size_t min_alloc, max_free;
-
- used_sentinel = &SMS_TRIVIAL_T(sms)->used_sentinel;
- free_sentinel = &SMS_TRIVIAL_T(sms)->free_sentinel;
-
- free_list = NULL;
-
- if (sms->sms_lock)
- apr_lock_acquire(sms->sms_lock);
-
- /* Always reset our base node as this can't be reclaimed. */
- node = SMS_TRIVIAL_T(sms)->self;
- node->avail_size += node->first_avail - ((char *)node + SIZEOF_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
- node->count = 0;
- node->prev->next = node->next;
- node->next->prev = node->prev;
-
- /* used_sentinel->prev may be currently "active", so disable it. */
- node = used_sentinel->prev;
- node->avail_size += node->first_avail - ((char *)node + SIZEOF_NODE_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
-
- if (sms->parent->free_fn) {
- /* We only reserve max_free bytes. The rest will be passed to the
- * parent SMS to be freed.
- */
- min_alloc = SMS_TRIVIAL_T(sms)->min_alloc;
- max_free = SMS_TRIVIAL_T(sms)->max_free;
-
- used_sentinel->avail_size = min_alloc;
-
- while (max_free > min_alloc) {
- if (node->avail_size <= max_free) {
- if (node == used_sentinel)
- break;
- /* These are the nodes that will NOT be freed, but
- * placed on the free list for later reuse.
- */
- max_free -= node->avail_size;
-
- node->prev->next = node->next;
- node->next->prev = node->prev;
-
- prev = node->prev;
-
- node->next = free_sentinel->next;
- free_sentinel->next = node;
- node->next->prev = node;
- node->prev = free_sentinel;
-
- node = prev;
- }
- else
- node = node->prev; /* Will be reclaimed. */
- }
-
- /* Remember that when sms->max_free hits zero, we free everything. */
- SMS_TRIVIAL_T(sms)->max_free = max_free;
-
- /* Anything remaining on the used_sentinel list will be freed. */
- used_sentinel->prev->next = NULL;
- free_list = used_sentinel->next;
- }
- else {
- /* Everything we have allocated goes into free_sentinel. */
- node = used_sentinel->prev;
- node->next = free_sentinel->next;
- node->next->prev = node;
-
- node = used_sentinel->next;
- node->prev = free_sentinel;
- free_sentinel->next = node;
- }
-
- /* Reset used_sentinel to just be the originally allocated node. */
- node = SMS_TRIVIAL_T(sms)->self;
- node->next = node->prev = used_sentinel;
- used_sentinel->next = used_sentinel->prev = node;
-
- if (sms->sms_lock)
- apr_lock_release(sms->sms_lock);
-
- while ((node = free_list) != NULL) {
- free_list = node->next;
- apr_sms_free(sms->parent, node);
- }
-
- return APR_SUCCESS;
-}
-
-static apr_status_t apr_sms_trivial_pre_destroy(apr_sms_t *sms)
-{
- /* This function WILL always be called. However, be aware that the
- * main sms destroy function knows that it's not wise to try and destroy
- * the same piece of memory twice, so the destroy function in a child won't
- * neccesarily be called.
- */
-
- return APR_SUCCESS;
-}
-
-static apr_status_t apr_sms_trivial_destroy(apr_sms_t *sms)
-{
- apr_sms_trivial_t *tms;
- node_t *node, *next;
-
- tms = SMS_TRIVIAL_T(sms);
- node = tms->self;
- node->next->prev = node->prev;
- node->prev->next = node->next;
-
- tms->free_sentinel.prev->next = NULL;
- tms->used_sentinel.prev->next = tms->free_sentinel.next;
-
- node = tms->used_sentinel.next;
- while (node) {
- next = node->next;
-
- apr_sms_free(sms->parent, node);
- node = next;
- }
-
- apr_sms_free(sms->parent, sms);
-
- return APR_SUCCESS;
-}
-
-#if APR_HAS_THREADS
-static apr_status_t apr_sms_trivial_thread_register(apr_sms_t *sms,
- apr_os_thread_t thread)
-{
- return APR_SUCCESS;
-}
-
-static apr_status_t apr_sms_trivial_thread_unregister(apr_sms_t *sms,
- apr_os_thread_t thread)
-{
- return APR_SUCCESS;
-}
-#endif /* APR_HAS_THREADS */
-
-APR_DECLARE(apr_status_t) apr_sms_trivial_create_ex(apr_sms_t **sms,
- apr_sms_t *pms,
- apr_size_t min_alloc,
- apr_size_t min_free,
- apr_size_t max_free)
-{
- apr_sms_t *new_sms;
- apr_sms_trivial_t *tms;
- node_t *node;
- apr_status_t rv;
-
- *sms = NULL;
-
- min_alloc = APR_ALIGN_DEFAULT(min_alloc);
- min_free = APR_ALIGN_DEFAULT(min_free);
- if (min_free < SIZEOF_NODE_T)
- min_free = SIZEOF_NODE_T;
-
- /* 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...
- */
-
- new_sms = apr_sms_calloc(pms, min_alloc);
- if (!new_sms)
- return APR_ENOMEM;
-
- if ((rv = apr_sms_init(new_sms, pms)) != APR_SUCCESS)
- return rv;
-
- new_sms->malloc_fn = apr_sms_trivial_malloc;
- new_sms->realloc_fn = apr_sms_trivial_realloc;
- new_sms->free_fn = apr_sms_trivial_free;
- new_sms->reset_fn = apr_sms_trivial_reset;
- new_sms->pre_destroy_fn = apr_sms_trivial_pre_destroy;
- new_sms->destroy_fn = apr_sms_trivial_destroy;
-#if APR_HAS_THREADS
- new_sms->thread_register_fn = apr_sms_trivial_thread_register;
- new_sms->thread_unregister_fn = apr_sms_trivial_thread_unregister;
-#endif /* APR_HAS_THREADS */
- new_sms->identity = module_identity;
-
- node = NODE_T((char *)new_sms + SIZEOF_SMS_TRIVIAL_T);
- node->first_avail = (char *)node + SIZEOF_NODE_T;
- node->avail_size = min_alloc - SIZEOF_SMS_TRIVIAL_T - SIZEOF_NODE_T;
- node->count = 0;
-
- tms = SMS_TRIVIAL_T(new_sms);
- tms->min_alloc = min_alloc;
- tms->min_free = min_free;
- tms->max_free = max_free;
- tms->self = node;
-
- node->next = node->prev = &tms->used_sentinel;
- tms->used_sentinel.next = tms->used_sentinel.prev = node;
- tms->free_sentinel.next = tms->free_sentinel.prev = &tms->free_sentinel;
-
- apr_sms_post_init(new_sms);
-
- *sms = new_sms;
- return APR_SUCCESS;
-}
-
-
-APR_DECLARE(apr_status_t) apr_sms_trivial_create(apr_sms_t **sms,
- apr_sms_t *pms)
-{
- return apr_sms_trivial_create_ex(sms, pms, MIN_ALLOC, MIN_FREE, MAX_FREE);
-}
-
diff --git a/memory/unix/sms_private.h b/memory/unix/sms_private.h
deleted file mode 100644
index 6542aec7d..000000000
--- a/memory/unix/sms_private.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-/**
- * @file sms_private.h
- * @brief SMS private definitions/routines
- * @internal
- */
-/**
- *
- * @defgroup APR_SMS_Private Private routines
- * @ingroup APR_SMS
- * @{
- */
-#ifndef SMS_PRIVATE_H
-#define SMS_PRIVATE_H
-
-#include "apr.h"
-#include "apr_errno.h"
-#include "apr_pools.h"
-#include "apr_lock.h"
-#include "apr_portable.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @struct apr_sms_t
- * @brief The SMS memory system structure
- */
-
-struct apr_sms_t
-{
- apr_sms_t *parent; /**< parent of the current SMS */
- apr_sms_t *child; /**< children of the current SMS */
- apr_sms_t *sibling; /**< next SMS at the same level */
- apr_sms_t **ref; /**< a pointer to the pointer pointing to memory */
- apr_sms_t *accounting; /**< SMS for accounting type tasks */
- const char *identity; /**< a string identifying the module */
-
- apr_pool_t *pool; /**< pool to associate with this SMS */
- apr_lock_t *sms_lock; /**< lock to use when allocated memory in this SMS */
-
- struct apr_sms_cleanup *cleanups; /**< stuff to call when the SMS is being freed */
-
- void * (*malloc_fn) (apr_sms_t *sms, apr_size_t size); /**< malloc fn for this SMS */
- void * (*calloc_fn) (apr_sms_t *sms, apr_size_t size); /**< calloc fn for this SMS */
- void * (*realloc_fn) (apr_sms_t *sms, void *memory,
- apr_size_t size); /**< realloc fn for this SMS */
- apr_status_t (*free_fn) (apr_sms_t *sms, void *memory); /**< free fn */
- apr_status_t (*reset_fn) (apr_sms_t *sms); /**< reset fn */
- apr_status_t (*pre_destroy_fn) (apr_sms_t *sms); /**< called before destroying memory */
- apr_status_t (*destroy_fn) (apr_sms_t *sms); /**< function to destory
-the SMS */
- apr_status_t (*lock_fn) (apr_sms_t *sms); /**< locking function */
- apr_status_t (*unlock_fn) (apr_sms_t *sms); /**< unlocking function */
-
- apr_status_t (*apr_abort)(int retcode); /**< function to call when a malloc fails */
- struct apr_hash_t *prog_data; /**< has to store userdata */
-
-#ifdef APR_POOLS_ARE_SMS
- struct process_chain *subprocesses;
-#endif
-
-#if APR_HAS_THREADS
- apr_status_t (*thread_register_fn) (apr_sms_t *sms,
- apr_os_thread_t thread);
- apr_status_t (*thread_unregister_fn) (apr_sms_t *sms,
- apr_os_thread_t thread);
- apr_uint16_t threads;
-#endif /* APR_HAS_THREADS */
-
-#if APR_DEBUG_TAG_SMS
- const char *tag;
-#endif
-};
-
-/*
- * private memory system functions
- */
-
-/**
- * Initialize a memory system
- * @warning Call this function as soon as you have obtained a block of memory
- * 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 sms The memory system created
- * @param parent_sms The parent memory system
- */
-APR_DECLARE(apr_status_t) apr_sms_init(apr_sms_t *sms,
- apr_sms_t *parent_sms);
-
-/**
- * Do post init work that needs the sms to have been fully
- * initialised.
- * @param sms The memory system to use
- * @return apr_status_t
- */
-APR_DECLARE(apr_status_t) apr_sms_post_init(apr_sms_t *sms);
-
-
-#ifdef __cplusplus
-}
-#endif
-/** @} */
-#endif /* !SMS_PRIVATE_H */
-
diff --git a/misc/netware/aprlib.imp b/misc/netware/aprlib.imp
index 2f7fe619e..6bbe7e432 100644
--- a/misc/netware/aprlib.imp
+++ b/misc/netware/aprlib.imp
@@ -227,39 +227,6 @@
apr_signal_get_description,
#apr_signal_thread,
apr_sleep,
- #apr_sms_assert,
- apr_sms_blocks_create,
- apr_sms_calloc,
- apr_sms_cleanup_register,
- apr_sms_cleanup_run,
- apr_sms_cleanup_run_type,
- apr_sms_cleanup_unregister,
- apr_sms_cleanup_unregister_type,
- apr_sms_destroy,
- #apr_sms_dump_stats,
- apr_sms_free,
- apr_sms_get_abort,
- apr_sms_get_identity,
- apr_sms_get_parent,
- apr_sms_is_ancestor,
- apr_sms_lock,
- apr_sms_malloc,
- apr_sms_realloc,
- apr_sms_reset,
- apr_sms_set_abort,
- #apr_sms_show_structure,
- apr_sms_std_create,
- #apr_sms_tag,
- apr_sms_thread_register,
- apr_sms_thread_unregister,
- apr_sms_threads_create,
- apr_sms_threads_create_ex,
- apr_sms_tracking_create,
- apr_sms_trivial_create,
- apr_sms_trivial_create_ex,
- apr_sms_unlock,
- apr_sms_userdata_get,
- apr_sms_userdata_set,
apr_snprintf,
apr_sockaddr_info_get,
apr_sockaddr_ip_get,
diff --git a/test/testmem.c b/test/testmem.c
index 38e55be7d..a2af1dae5 100644
--- a/test/testmem.c
+++ b/test/testmem.c
@@ -52,10 +52,6 @@
* <http://www.apache.org/>.
*/
-#include "apr_sms.h"
-#include "apr_sms_tracking.h"
-#include "apr_sms_trivial.h"
-#include "apr_sms_blocks.h"
#include "apr_errno.h"
#include "apr_general.h"
#include "apr_lib.h"
@@ -86,21 +82,9 @@ typedef struct _test_ {
apr_time_t howlong;
} _test_;
-#define T_QTY 5 /* how many tests do we have?? */
+#define T_QTY 1 /* how many tests do we have?? */
static _test_ t[T_QTY];
-static void its_an_sms(apr_sms_t *ams, _test_ *t, char *name, int lt)
-{
- t->malloc_fn = (void*)apr_sms_malloc;
- t->calloc_fn = (void*)apr_sms_calloc;
- t->free_fn = (void*)apr_sms_free;
- t->reset_fn = (void*)apr_sms_reset;
- t->memory = ams;
- t->title = name;
- t->large_tests = lt;
- t->howlong = 0;
-}
-
static void its_a_pool(apr_pool_t *pool, _test_ *t, char *name, int lt)
{
t->malloc_fn = (void*)apr_palloc;
@@ -422,12 +406,11 @@ static int timed_test_64byte(_test_ *t, int small, int verbose)
static void print_timed_results(void)
{
int i;
- printf(" Percentage Results averages %% of pools %% of std sms\n");
+ printf(" Percentage Results averages %% of pools\n");
for (i=0;i < T_QTY; i++) {
float pa = (float)t[i].howlong / (float)t[0].howlong;
- float pb = (float)t[i].howlong / (float)t[1].howlong;
- printf(" %-20s %-8lld %7.02f %% %7.02f %%\n", t[i].title, t[i].howlong,
- pa * 100, pb * 100);
+ printf(" %-20s %-8lld %7.02f %%\n", t[i].title, t[i].howlong,
+ pa * 100);
}
printf("\n");
for (i=0;i<T_QTY;i++)
@@ -436,10 +419,8 @@ static void print_timed_results(void)
int main(int argc, char **argv)
{
- apr_sms_t *ams, *bms, *dms, *tms;
apr_pool_t *pool;
int i;
- apr_sms_t *lsms[10];
apr_initialize();
@@ -449,44 +430,9 @@ int main(int argc, char **argv)
printf("Creating the memory systems...\n");
STD_TEST_NEQ(" Creating a pool",
apr_pool_create(&pool, NULL))
- STD_TEST_NEQ(" Creating the standard memory system",
- apr_sms_std_create(&ams))
- STD_TEST_NEQ(" Creating the tracking memory system",
- apr_sms_tracking_create(&bms, ams))
- STD_TEST_NEQ(" Creating a 64 byte block system",
- apr_sms_blocks_create(&dms, ams, 64))
- STD_TEST_NEQ(" Creating a trivial system",
- apr_sms_trivial_create(&tms, ams))
-
-/* if we're using tag's then add them :) */
-#if APR_DEBUG_TAG_SMS
- apr_sms_tag("top-level", ams);
- apr_sms_tag("tracking", bms);
- apr_sms_tag("blocks", dms);
- apr_sms_tag("trivial", tms);
-#endif
its_a_pool(pool, &t[0], "Pool code", 1);
- its_an_sms(ams, &t[1], "Standard sms", 1);
- t[1].reset_fn = NULL;
- its_an_sms(bms, &t[2], "Tracking sms", 1);
- its_an_sms(dms, &t[3], "Blocks sms", 0);
- its_an_sms(tms, &t[4], "Trivial sms", 1);
- printf("Checking sms identities...\n");
- TEST_NEQ(" Checking identity of standard memory system",
- strcmp(apr_sms_get_identity(ams), "STANDARD"), 0,
- "OK","Not STANDARD")
- TEST_NEQ(" Checking the identity of tracking memory system",
- strcmp(apr_sms_get_identity(bms), "TRACKING"), 0,
- "OK", "Not TRACKING")
- TEST_NEQ(" Checking the identity of blocks memory system",
- strcmp(apr_sms_get_identity(dms), "BLOCKS"), 0,
- "OK", "Not BLOCKS")
- TEST_NEQ(" Checking the identity of trivial memory system",
- strcmp(apr_sms_get_identity(tms), "TRIVIAL"), 0,
- "OK", "Not TRIVIAL")
-
printf("Big allocation test...\n");
for (i = 0; i < T_QTY; i++) {
if (simple_test(&t[i], 0)) {
@@ -523,26 +469,6 @@ int main(int argc, char **argv)
}
print_timed_results();
- printf("Destroying the memory...\n");
-
- STD_TEST_NEQ("Trying to destroy the trivial memory system",
- apr_sms_destroy(tms))
- STD_TEST_NEQ("Trying to destroy the tracking memory system",
- apr_sms_destroy(bms))
- STD_TEST_NEQ("Trying to destroy the block memory system",
- apr_sms_destroy(dms))
-
- printf("Testing layering...\n");
- apr_sms_tracking_create(&lsms[0], ams);
- for (i=1;i<5;i++) {
- apr_sms_tracking_create(&lsms[i], lsms[i-1]);
- }
- for (i=5;i<10;i++) {
- apr_sms_tracking_create(&lsms[i], lsms[4]);
- }
- STD_TEST_NEQ("Trying to destroy the standard memory system",
- apr_sms_destroy(ams))
-
printf("Memory test passed.\n");
return (0);
}
diff --git a/test/testud.c b/test/testud.c
index d98b224e7..443051b7e 100644
--- a/test/testud.c
+++ b/test/testud.c
@@ -59,7 +59,6 @@
#include "apr_general.h"
#include "apr_lib.h"
#include "apr_strings.h"
-#include "apr_sms.h"
#include "test_apr.h"
static apr_status_t string_cleanup(void *data)
@@ -70,7 +69,6 @@ static apr_status_t string_cleanup(void *data)
int main(void)
{
apr_pool_t *pool;
- apr_sms_t *sms;
char *testdata;
char *retdata;
@@ -80,7 +78,6 @@ int main(void)
atexit(apr_terminate);
STD_TEST_NEQ("Creating a pool", apr_pool_create(&pool, NULL))
- STD_TEST_NEQ("Creating an sms", apr_sms_std_create(&sms))
testdata = apr_pstrdup(pool, "This is a test\n");
@@ -94,17 +91,6 @@ int main(void)
TEST_NEQ(" Checking the data we got", strcmp(testdata, retdata),
0, "OK","Failed :(")
- printf("Testing SMS\n");
-
- STD_TEST_NEQ(" Setting user data into the pool",
- apr_sms_userdata_set(testdata, "TEST", string_cleanup, sms))
-
- STD_TEST_NEQ(" Getting user data from the pool",
- apr_sms_userdata_get((void **)&retdata, "TEST", sms))
-
- TEST_NEQ(" Checking the data we got", strcmp(testdata, retdata),
- 0, "OK","Failed :(")
-
printf("\nTest complete\n");
return 0;
}