Memory allocation still not properly aligned.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 28, 2010 at 6:45 PM, John Ridges <jridges at masque.com> wrote:
> I can see that you did fix the alignment in "pj_pool_create_block", but as
> near as I can tell that function is only called by "pj_pool_allocate_find"
> when the current blocks can't satisfy a request and a new block needs to be
> created. The problem seems to be that (for a caching pool factory) the very
> first block is created with a different function, "pj_pool_create_int", and
> that function is not setting the alignment properly. And as long as we're on
> the subject, it looks like the "reset_pool" function also sets the alignment
> for the remaining block incorrectly as well, but I haven't noticed because I
> don't use it.
>
> Also, I noticed that the code you used to align the memory in
> "pj_pool_create_block", namely:
>
> ? ?block->cur = (unsigned char*)
> ? ? ? ? ? ? ? ?(((unsigned long)block->buf + PJ_POOL_ALIGNMENT - 1) &
> ? ? ? ? ? ? ? ? ~(PJ_POOL_ALIGNMENT - 1));
>
> doesn't work in 64-bit Windows because "long" is still only 32 bits wide. A
> way of doing this that doesn't have that problem is:
>
> ? block->cur = block_buf + (-(long)(block->buf) & (PJ_POOL_ALIGNMENT-1));
>
> I hope this makes sense.
>

You're right on all points, I just fixed them in
http://trac.pjsip.org/repos/ticket/1037

Thanks
 Benny



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux