[haiku-development] Re: Help with memory allocation in WebKit JavaScriptCore

  • From: Bryan Varner <bryan@xxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 15 Aug 2007 23:41:08 -0400

> The main problem I'm having is with the memory allocation method.
> Basically what seems to be needed is a way to allocate memory in a
> nice aligned chunk. One way to do this is with the function
> posix_memalign:
> 
>
http://www.opengroup.org/onlinepubs/000095399/functions/posix_memalign.html
> 
> Haiku doesn't seem to implement this. The relevant bit of code is here:

This function should do the trick.
haiku/headers/posix/malloc.h:20
extern void *memalign(size_t alignment, size_t numBytes);

> http://pastie.caboo.se/88124

I think something like... 

#elif PLATFORM(HAIKU)
    void *address = memalign(BLOCK_SIZE, BLOCK_SIZE);
    memset(reinterpret_cast<void*>(address), 0, BLOCK_SIZE);
#else
   ...

might just do the trick.

I'm not kernel guru, but hopefully this gets you somewhere.

Regards,
-Bryan


Other related posts: