apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cliff Woolley <cliffwool...@yahoo.com>
Subject Re: [PATCH] sms blocks
Date Fri, 15 Jun 2001 04:12:47 GMT
On Thu, 14 Jun 2001, Luke Kenneth Casson Leighton wrote:

> you are aware that strictly speaking you are _not_ supposed
> to treat memory addresses as contiguous?
> one of the reasons why void* _is_ void* is because
> potentially, areas of memory allocated by a system
> may be from different regions, and not contiguous.

Uhh.. well, yeah, of course.  I was speaking strictly about this
particular implementation of apr_sms_blocks, which does its dirty deed by
pre-allocating a single big block (8K I think) and then carving it up into
little sub-blocks which it hands out.  Only if it cannot fulfill the
apr_sms_blocks_malloc() request with one of those sub-blocks will it call
parent->malloc_fn().  So all you have to do in apr_sms_blocks_free() to
find out if the address you were given is one of your sub-blocks or
something else (ie, something you got from parent->malloc_fn()) is to
check if the address is outside your single big block.  If it is outside,
then you MUST have gotten that memory block from your parent.  If it is
inside, then it MUST be one of your sub-blocks.


   Cliff Woolley
   Charlottesville, VA

View raw message