apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr-util/misc apr_rmm.c
Date Wed, 09 Jan 2002 05:13:33 GMT
wrowe       02/01/08 21:13:33

  Modified:    misc     apr_rmm.c
  Log:
    Collapse a block upon free into it's previous and/or next block
    when the blocks are adjacent.
  
  Revision  Changes    Path
  1.6       +22 -3     apr-util/misc/apr_rmm.c
  
  Index: apr_rmm.c
  ===================================================================
  RCS file: /home/cvs/apr-util/misc/apr_rmm.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- apr_rmm.c	8 Jan 2002 13:00:55 -0000	1.5
  +++ apr_rmm.c	9 Jan 2002 05:13:33 -0000	1.6
  @@ -193,13 +193,32 @@
       /* and open it up */
       if (blk->prev) {
           struct rmm_block_t *prev = (rmm_block_t*)((char*)rmm->base + blk->prev);
  -        blk->next = prev->next;
  -        prev->next = this;
  +        if (free && (blk->prev + prev->size == this)) {
  +            /* Collapse us into our predecessor */
  +            prev->size += blk->size;
  +            this = blk->prev;
  +            blk = prev;
  +        }
  +        else {
  +            blk->next = prev->next;
  +            prev->next = this;
  +        }
       }
   
       if (blk->next) {
           struct rmm_block_t *next = (rmm_block_t*)((char*)rmm->base + blk->next);
  -        next->prev = this;
  +        if (free && (this + blk->size == blk->next)) {
  +            /* Collapse us into our successor */
  +            blk->size += next->size;
  +            blk->next = next->next;
  +            if (blk->next) {
  +                next = (rmm_block_t*)((char*)rmm->base + blk->next);
  +                next->prev = this;
  +            }
  +        }
  +        else {
  +            next->prev = this;
  +        }
       }
   }
   
  
  
  

Mime
View raw message