Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 如果 free() 知道我的数组的长度,为什么我不能在我自己的代码中要求它?
环顾四周(包括在stackoverflow),我发现 malloc() 分配了一个数组并创建了一个标头来控制数组信息。
在此标头中,还有数组大小。free() 使用这些信息来了解如何释放该数组。
那么,如果数组大小信息在“那里”(在内存中的某个位置),为什么没有返回数组大小的函数,在数组头中寻找它?还是我错过了什么?