On Dec 25, 2008, at 4:51 AM, Oliver Hunt wrote:

You can manually align the memory, eg.
char* memory = malloc(size + alignment - 1);
memory += alignment;
memory &= ~(alignment - 1)
return memory;

The obvious problem with this is that you can't directly free the result as it will not necessarily represent the start of the allocation, but there are mechanisms for working around that (storing the initial allocation address inline in the allocation itself for instance) but there are various trade offs involved.

Doing it this way would also waste memory, specifically it would allocate nearly twice the requested size for a block. (It should also work on Symbian though).


--Oliver

On Dec 25, 2008, at 3:14 AM, Javed Rabbani wrote:

Oliver,

Thanks a great deal for this explanation. I am considering running JS SquirrelFish extreme engine on an ARM-based embedded platform. You are right that posix systems should provide mmap or posix_memalign that will serve the purpose. I am concerned about this issue because in my case, there is no mmap, vm_map etc. to do the job. The only available option is to use standard memory allocation routines. What is the way out for me to deal with such a situation? Obviously, standard malloc() call from within fastMalloc() is not doing anything good for me.


Regards,
J R Shah


_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to