Archived

This topic is now archived and is closed to further replies.

gonen

help with aligned malloc

Recommended Posts

i need help with a problem i need to rewrite the malloc (c only) to allocate memory that is byte aligned, using the normal malloc. the new procedure must allocate enough space needed by the request (add more space from original request if needed). there should be no problem calling malloc and free (could be few requests for malloc before a request for free) if needed , also rewrite the free function please help me solve this problem

Share this post


Link to post
Share on other sites
We don''t do your homework for you. What have you tried so far? What concepts, if any, do you not fully understand? What specific questions do you have?


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
So what''s your problem? You need to allocate enough memory to hold the request plus alignment and return an aligned pointer. You already stated what you need to do, what part is giving you problems?

P.S. ftp://gee.cs.oswego.edu/pub/misc/malloc.c contains a free to use/distribute/modify implementation of malloc that allows for arbitrary alignment specification. Warning, the code is very ugly, hard to read, and uses way too many macros c code.

Share this post


Link to post
Share on other sites