apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Allan Edwards <a...@us.ibm.com>
Subject Re: [PATCH] WIN64: apr_pools.c
Date Thu, 30 Sep 2004 15:22:41 GMT
Joe Orton wrote:
> It is part of the API, it can't be changed like this in 1.x.  You can't
> use the apr_allocator_* API without using the apr_memnode_t structure,

The allocator API uses an incomplete type for apr_allocator_t and
in the same way should (actually it does) use an incomplete type
for apr_memnode_t. It just seems like an oversight that the definition
of apr_memnode_t was left in apr_allocator.h

> so I don't see how it could be made private either.

This patch demonstates that it can be made private,
httpd builds cleanly against it. The only reason I
can see that this breaks the API is if someone were
doing strange and unnatural things outside of the
normal use of the API. Do we want to deny this change
because of that remote possibility?

Allan


Index: apr/include/apr_allocator.h
===================================================================
RCS file: /home/cvs/apr/include/apr_allocator.h,v
retrieving revision 1.19
diff -U3 -r1.19 apr_allocator.h
--- apr/include/apr_allocator.h	13 Feb 2004 09:38:28 -0000	1.19
+++ apr/include/apr_allocator.h	30 Sep 2004 15:09:58 -0000
@@ -41,27 +41,6 @@
  /** the structure which holds information about the allocation */
  typedef struct apr_memnode_t apr_memnode_t;

-/** basic memory node structure
- * @note The next, ref and first_avail fields are available for use by the
- *       caller of apr_allocator_alloc(), the remaining fields are read-only.
- *       The next field has to be used with caution and sensibly set when the
- *       memnode is passed back to apr_allocator_free().  See apr_allocator_free()
- *       for details.
- *       The ref and first_avail fields will be properly restored by
- *       apr_allocator_free().
- */
-struct apr_memnode_t {
-    apr_memnode_t *next;            /**< next memnode */
-    apr_memnode_t **ref;            /**< reference to self */
-    apr_uint32_t   index;           /**< size */
-    apr_uint32_t   free_index;      /**< how much free */
-    char          *first_avail;     /**< pointer to first free memory */
-    char          *endp;            /**< pointer to end of free memory */
-};
-
-/** The base size of a memory node - aligned.  */
-#define APR_MEMNODE_T_SIZE APR_ALIGN_DEFAULT(sizeof(apr_memnode_t))
-
  /** Symbolic constants */
  #define APR_ALLOCATOR_MAX_FREE_UNLIMITED 0

Index: apr/memory/unix/apr_pools.c
===================================================================
RCS file: /home/cvs/apr/memory/unix/apr_pools.c,v
retrieving revision 1.206
diff -U3 -r1.206 apr_pools.c
--- apr/memory/unix/apr_pools.c	17 Jun 2004 14:13:58 -0000	1.206
+++ apr/memory/unix/apr_pools.c	30 Sep 2004 15:09:58 -0000
@@ -21,7 +21,7 @@
  #include "apr_strings.h"
  #include "apr_general.h"
  #include "apr_pools.h"
-#include "apr_allocator.h"
+#include "arch/unix/apr_arch_allocator.h"
  #include "apr_lib.h"
  #include "apr_thread_mutex.h"
  #include "apr_hash.h"
@@ -63,9 +63,9 @@
   */

  struct apr_allocator_t {
-    apr_uint32_t        max_index;
-    apr_uint32_t        max_free_index;
-    apr_uint32_t        current_free_index;
+    apr_size_t          max_index;
+    apr_size_t          max_free_index;
+    apr_size_t          current_free_index;
  #if APR_HAS_THREADS
      apr_thread_mutex_t *mutex;
  #endif /* APR_HAS_THREADS */
@@ -141,7 +141,7 @@
  APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator,
                                               apr_size_t size)
  {
-    apr_uint32_t max_free_index;
+    apr_size_t max_free_index;

  #if APR_HAS_THREADS
      apr_thread_mutex_t *mutex;
@@ -168,7 +168,7 @@
  apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size)
  {
      apr_memnode_t *node, **ref;
-    apr_uint32_t i, index, max_index;
+    apr_size_t i, index, max_index;

      /* Round up the block size to the next boundary, but always
       * allocate at least a certain size (MIN_ALLOC).
@@ -304,8 +304,8 @@
  void allocator_free(apr_allocator_t *allocator, apr_memnode_t *node)
  {
      apr_memnode_t *next, *freelist = NULL;
-    apr_uint32_t index, max_index;
-    apr_uint32_t max_free_index, current_free_index;
+    apr_size_t index, max_index;
+    apr_size_t max_free_index, current_free_index;

  #if APR_HAS_THREADS
      if (allocator->mutex)
@@ -582,7 +582,7 @@
  {
      apr_memnode_t *active, *node;
      void *mem;
-    apr_uint32_t free_index;
+    apr_size_t free_index;

      size = APR_ALIGN_DEFAULT(size);
      active = pool->active;
@@ -877,7 +877,7 @@
      apr_size_t cur_len, size;
      char *strp;
      apr_pool_t *pool;
-    apr_uint32_t free_index;
+    apr_size_t free_index;

      pool = ps->pool;
      active = ps->node;
@@ -948,7 +948,7 @@
      char *strp;
      apr_size_t size;
      apr_memnode_t *active, *node;
-    apr_uint32_t free_index;
+    apr_size_t free_index;

      ps.node = active = pool->active;
      ps.pool = pool;
Index: apr-util/buckets/apr_buckets_alloc.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_alloc.c,v
retrieving revision 1.16
diff -U3 -r1.16 apr_buckets_alloc.c
--- apr-util/buckets/apr_buckets_alloc.c	10 Aug 2004 22:00:16 -0000	1.16
+++ apr-util/buckets/apr_buckets_alloc.c	30 Sep 2004 15:09:59 -0000
@@ -16,7 +16,7 @@
  #include <stdlib.h>

  #include "apr_buckets.h"
-#include "apr_allocator.h"
+#include "arch/unix/apr_arch_allocator.h"

  #define ALLOC_AMT (8192 - APR_MEMNODE_T_SIZE)





Mime
View raw message