我很好奇是否存在允许程序员释放部分已分配块的动态内存分配系统。
例如:
char* a = malloc (40);
//b points to the split second half of the block, or to NULL if it's beyond the end
//a points to a area of 10 bytes
b = partial_free (a+10, /*size*/ 10)
关于为什么这是明智/不明智/困难的想法?这样做的方法?
在我看来,它可能很有用。
谢谢!
=====edit===== 经过一番研究,似乎 linux 内核的 bootmem 分配器允许与 bootmem_free 调用类似的操作。所以,我很好奇——为什么 bootmem 分配器允许这样做,但 ANSI C 不允许?