Is there a way to change where malloc allocate memory space?
For an example, let's say I want malloc to allocate memory within 0x100000 and 0x500000. How can I do this or is there a way for this without changing the malloc implementation?
Is there a way to change where malloc allocate memory space?
For an example, let's say I want malloc to allocate memory within 0x100000 and 0x500000. How can I do this or is there a way for this without changing the malloc implementation?
You probably cannot change the behavior of the standard malloc
call (aside from runtime substitutions such as via LD_PRELOAD), but for some platforms can write your own (separate) memory allocator using specific addresses with the mmap function call.
Using malloc allocates memory on the heap.If your question is related to an embedded software, you can often change the heap start address,size and other parameters in the startup file or linker configuration file.