Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Modifying malloc( ) implementation
I have a big chunk of memory (128M), which is divided into 4 memory banks.. Now, I am supposed to make efficient memory utilization,and for that purpose, I NEED TO ALLOCATE MEMORY FROM THE ADDRESSES I PROVIDE. Now, here's what the problem... We have a system defined malloc( ) source which I'm not supposed to change.
So, one way I can think of is...
do a malloc and compare with the address I want to allocate memory at.
if not equal, then call malloc again, & free the previous memory
continue this till I reach the address I want to allocate memory at
But this is really very inefficient and slow method..
Since I'm not supposed to change the malloc source code,
Does somebody have any idea how to trick the heap manager, or by some pointer manipulations, or by writing wrapper routines, anyway, so that I can allocate a memory chunk at the address I provide.
0 · ·