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? -- Bojan
