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 Thu, 30 Oct 2003 11:39:37 GMT
striker     2003/10/30 03:39:37

  Modified:    memory/unix Tag: APR_0_9_BRANCH apr_pools.c
  Log:
  Backport from 1.0
  
  Submitted by:	Joe Orton
  Reviewed by:	Greg Stein, Cliff Woolley, Sander Striker
  
  * memory/unix/apr_pools.c
  
    (list_insert, list_remove): new macros to do manipulation of lists
      throughout the pools code.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.197.2.4 +26 -37    apr/memory/unix/apr_pools.c
  
  Index: apr_pools.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_pools.c,v
  retrieving revision 1.197.2.3
  retrieving revision 1.197.2.4
  diff -u -r1.197.2.3 -r1.197.2.4
  --- apr_pools.c	28 Sep 2003 17:14:21 -0000	1.197.2.3
  +++ apr_pools.c	30 Oct 2003 11:39:36 -0000	1.197.2.4
  @@ -615,6 +615,21 @@
   }
   #endif /* defined(NETWARE) */
   
  +/* Node list management helper macros; list_insert() inserts 'node'
  + * before 'point'. */
  +#define list_insert(node, point) do {           \
  +    node->ref = point->ref;                     \
  +    *node->ref = node;                          \
  +    node->next = point;                         \
  +    point->ref = &node->next;                   \
  +} while (0)
  +
  +/* list_remove() removes 'node' from its list. */
  +#define list_remove(node) do {                  \
  +    *node->ref = node->next;                    \
  +    node->next->ref = node->ref;                \
  +} while (0)
  +
   /*
    * Memory allocation
    */
  @@ -638,8 +653,7 @@
   
       node = active->next;
       if (size < (apr_size_t)(node->endp - node->first_avail)) {
  -        *node->ref = node->next;
  -        node->next->ref = node->ref;
  +        list_remove(node);
       }
       else {
           if ((node = allocator_alloc(pool->allocator, size)) == NULL) {
  @@ -655,10 +669,7 @@
       mem = node->first_avail;
       node->first_avail += size;
   
  -    node->ref = active->ref;
  -    *node->ref = node;
  -    node->next = active;
  -    active->ref = &node->next;
  +    list_insert(node, active);
   
       pool->active = node;
   
  @@ -675,13 +686,8 @@
       }
       while (free_index < node->free_index);
   
  -    *active->ref = active->next;
  -    active->next->ref = active->ref;
  -
  -    active->ref = node->ref;
  -    *active->ref = active;
  -    active->next = node;
  -    node->ref = &active->next;
  +    list_remove(active);
  +    list_insert(active, node);
   
       return mem;
   }
  @@ -944,13 +950,9 @@
       node = active->next;
       if (!ps->got_a_new_node
           && size < (apr_size_t)(node->endp - node->first_avail)) {
  -        *node->ref = node->next;
  -        node->next->ref = node->ref;
   
  -        node->ref = active->ref;
  -        *node->ref = node;
  -        node->next = active;
  -        active->ref = &node->next;
  +        list_remove(node);
  +        list_insert(node, active);
   
           node->free_index = 0;
   
  @@ -967,13 +969,8 @@
               }
               while (free_index < node->free_index);
   
  -            *active->ref = active->next;
  -            active->next->ref = active->ref;
  -
  -            active->ref = node->ref;
  -            *active->ref = active;
  -            active->next = node;
  -            node->ref = &active->next;
  +            list_remove(active);
  +            list_insert(active, node);
           }
   
           node = pool->active;
  @@ -1058,10 +1055,7 @@
   
       node->free_index = 0;
   
  -    node->ref = active->ref;
  -    *node->ref = node;
  -    node->next = active;
  -    active->ref = &node->next;
  +    list_insert(node, active);
   
       pool->active = node;
   
  @@ -1079,13 +1073,8 @@
       }
       while (free_index < node->free_index);
   
  -    *active->ref = active->next;
  -    active->next->ref = active->ref;
  -
  -    active->ref = node->ref;
  -    *active->ref = active;
  -    active->next = node;
  -    node->ref = &active->next;
  +    list_remove(active);
  +    list_insert(active, node);
   
       return strp;
   }
  
  
  

Mime
View raw message