apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stri...@apache.org
Subject cvs commit: apr/memory/unix apr_pools.c
Date Sat, 09 Feb 2002 14:08:40 GMT
striker     02/02/09 06:08:40

  Modified:    include  apr_pools.h
               memory/unix apr_pools.c
  Log:
  Rename apr_find_pool to apr_pool_find.  Implement it in terms of
  apr_pool_walk_tree (which makes it thread safe).
  
  Revision  Changes    Path
  1.78      +2 -2      apr/include/apr_pools.h
  
  Index: apr_pools.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_pools.h,v
  retrieving revision 1.77
  retrieving revision 1.78
  diff -u -r1.77 -r1.78
  --- apr_pools.h	5 Feb 2002 12:09:43 -0000	1.77
  +++ apr_pools.h	9 Feb 2002 14:08:39 -0000	1.78
  @@ -573,7 +573,7 @@
    * if the data is allocated in any ancestor of T's pool.  This is the
    * basis on which the APR_POOL_DEBUG code works -- it tests these ancestor
    * relationships for all data inserted into tables.  APR_POOL_DEBUG also
  - * provides tools (apr_find_pool, and apr_pool_is_ancestor) for other
  + * provides tools (apr_pool_find, and apr_pool_is_ancestor) for other
    * folks to implement similar restrictions for their own data
    * structures.
    *
  @@ -606,7 +606,7 @@
    * @param mem The thing allocated in the pool
    * @return The pool it is allocated in
    */
  -APR_DECLARE(apr_pool_t *) apr_find_pool(const void *mem);
  +APR_DECLARE(apr_pool_t *) apr_pool_find(const void *mem);
   
   /**
    * Report the number of bytes currently in the pool
  
  
  
  1.153     +19 -19    apr/memory/unix/apr_pools.c
  
  Index: apr_pools.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_pools.c,v
  retrieving revision 1.152
  retrieving revision 1.153
  diff -u -r1.152 -r1.153
  --- apr_pools.c	8 Feb 2002 18:38:15 -0000	1.152
  +++ apr_pools.c	9 Feb 2002 14:08:39 -0000	1.153
  @@ -1402,37 +1402,37 @@
   {
   }
   
  -static apr_pool_t *find_pool(apr_pool_t *pool, const void *mem)
  +static int pool_find(apr_pool_t *pool, void *data)
   {
  -    apr_pool_t *found;
  +    void **pmem = (void **)data;
       debug_node_t *node;
       apr_uint32_t index;
   
  -    while (pool) {
  -        node = pool->nodes;
  +    node = pool->nodes;
   
  -        while (node) {
  -            for (index = 0; index < node->index; index++) {
  -                if (node->beginp[index] <= mem &&
  -                    node->endp[index] > mem)
  -                    return pool;
  -            }
  -
  -            node = node->next;
  +    while (node) {
  +        for (index = 0; index < node->index; index++) {
  +             if (node->beginp[index] <= *pmem &&
  +                 node->endp[index] > *pmem) {
  +                 *pmem = pool;
  +                 return 1;
  +             }
           }
   
  -        if ((found = find_pool(pool->child, mem)) != NULL)
  -            return found;
  -
  -        pool = pool->sibling;
  +        node = node->next;
       }
   
  -    return NULL;
  +    return 0;
   }
   
  -APR_DECLARE(apr_pool_t *) apr_find_pool(const void *mem)
  +APR_DECLARE(apr_pool_t *) apr_pool_find(const void *mem)
   {
  -    return find_pool(global_pool, mem);
  +    void *pool = mem;
  +
  +    if (apr_pool_walk_tree(global_pool, pool_find, &pool))
  +        return pool;
  +
  +    return NULL;
   }
   
   static int pool_num_bytes(apr_pool_t *pool, void *data)
  
  
  

Mime
View raw message