apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bojan Smojver <bo...@rexursive.com>
Subject Re: Why the 'size' is aligned twice in apr_pCalloc()
Date Mon, 12 May 2008 03:49:09 GMT
On Mon, 2008-05-12 at 11:19 +0800, zengwm wrote:

> apr_pCalloc() calls apr_palloc() to do the memory allocation in the
> pool. It aligns the 'size' parameter before calling apr_palloc(). And
> the size is aligned again in apr_palloc().
> Why 'size' has to be aligned twice? Can the first alignment ( in
> apr_pCalloc() ) be omitted?
> I don't think omitting the first alignment will affect the memset()
> call later in apr_pCalloc(), because, from the users' point of view,
> it's guaranteed that all the memory he can see has been Zero-out.

This may be an artifact of the old implementation of apr_pcalloc(),
which did not call apr_palloc().

I'd be inclined to agree with your reasoning here, but because I didn't
actually implement this function, I don't know if there could be some
hidden reliance on the total aligned size being zeroed here.

Anyone else cares to comment?


View raw message