Jump to content
  • Advertisement

Archived

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

gonen

help with aligned malloc

This topic is 5519 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
this is not a homework question , and im not getting paid to solve it , if you dont wanna help please dont reply

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
well , i can align the size , but i have problem with the free , i dont know how to free the memory

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!