Skip to main content
gamedev.net
🔒 Locked

help with aligned malloc

Started by gonen Aug 11, 2003 at 9:46 AM 6 replies 2.8k views
Original Post
gonen
gonen
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
Sneftel
Sneftel
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.
gonen
gonen
this is not a homework question , and im not getting paid to solve it , if you dont wanna help please dont reply
JohnBolton
JohnBolton
"byte aligned"?
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
gonen
gonen
im sorry , 8 byte aligned (or 16)
chiuyan
chiuyan
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.
gonen
gonen
well , i can align the size , but i have problem with the free , i dont know how to free the memory
gonen
gonen
well , i downloaded your link , seems huge

the solution is probably 5-10 lines of code so please someone who knows what he''s doing help me

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.