如果我们试图释放一个指向 NULL 的指针,内存中会发生什么? 这是否有效?
为什么它不显示任何警告/错误消息?
最佳答案
摘自 C99 第 7.20.3.2 节:free 函数
概要
1 #include <stdlib.h>
void free(void *ptr);
描述
2 The free function causes the space pointed to by ptr to be deallocated, that is, made available for further allocation. If ptr is a null pointer, no action occurs.
关于c - 释放空指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50113535/