c malloc function rollback

I'm working on a chip that has two different volatile memory (say RAM0 and RAM1) which the default memory for runtime variables is RAM0. I've moved the heap area (using memory description file) to the RAM1 area in order to utilize that memory.

As I said the runtime variables are still located in RAM0 address space so when I call malloc and free fuctions some changes occur in related variables on RAM0. By the way, the RAM1 address space is also used by other parts of code as temporary memory, so stored values on this memory will be changed by others.

My problem is that after first call of malloc function it seems that some initialization occurs and some values are stored in malloc specific runtime variables and RAM1 area that will not be reset even after calling free function, but if other parts of code change the values on RAM1 the malloc function will fail after calling again because the pointers and runtime values of malloc function are changed in a wrong way.

Is there any way that whole configuration data of malloc mechanism (that after first call of malloc function are set) be reset in a way that it seems no malloc call occured yet? I want to reset whole data related to malloc function before each call of malloc function. How's that possible?

链接地址: http://www.djcxy.com/p/82532.html

上一篇: 数组在C中存储在哪里?

下一篇: c malloc函数回滚