apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Pane <bp...@pacbell.net>
Subject [PATCH] bucket alloc: a simpler approach
Date Sat, 30 Mar 2002 07:05:16 GMT
While prototyping an apr_allocator_t based implementation for the
bucket allocator, I suddenly realized that there may be a much simpler
way to solve the problem.

The attached implementation handles allocation requests differently
based on their size:

  * Anything <= 128 bytes is allocated from a free list of 128-byte
    blocks contained within the bucket allocator.  When the free list
    runs out of blocks, the bucket allocator gets additional memory
    from its pool.  (We can do this because the allocator's lifetime
    is the same as that of the pool from which it was created.)

  * Anything > 128 bytes is handled using malloc/free.  The only
    common case larger than 128 is 8192.  It would be easy to add
    a second free list within the allocator for 8192-byte blocks.
    For this free list, we should probably impose a max size, so
    that we never store more than two or three 8KB blocks in an



View raw message