当您尝试释放(c)中已经释放的内存会发生什么? [英] What happens when you try to free() already freed memory in c?
本文介绍了当您尝试释放(c)中已经释放的内存会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:
char * myString = malloc(sizeof(char)*STRING_BUFFER_SIZE);
free(myString);
free(myString);
是否有这样做的任何不良副作用?
Are there any adverse side effects of doing this?
推荐答案
下面的篇章,段落。
如果参数[到免费
功能]不匹配前面返回的指针释放calloc
,的malloc
或
的realloc
函数,或者如果空间已释放通过调用免费
或 realloc的
,
该行为是不确定的。 ( ISO 9899:1999 - 编程语言 - ç的,第7.20.3.2)
If the argument [to the
free
function] does not match a pointer earlier returned by thecalloc
,malloc
, orrealloc
function, or if the space has been deallocated by a call tofree
orrealloc
, the behavior is undefined. (ISO 9899:1999 - Programming languages — C, Section 7.20.3.2)
这篇关于当您尝试释放(c)中已经释放的内存会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文