请教动态内存释放函数free

[复制链接]
3359|5
 楼主| ayb_ice 发表于 2011-10-26 08:36 | 显示全部楼层 |阅读模式
KEIL C51明确明说
如果free函数参数是空指针的话将会被忽略,请问标准C是这样的吗
上官金虹 发表于 2011-10-26 09:06 | 显示全部楼层
http://www.cplusplus.com/reference/clibrary/cstdlib/free/

void free ( void * ptr );
Deallocate space in memory

A block of memory previously allocated using a call to malloc, calloc or realloc is deallocated, making it available again for further allocations.

Notice that this function leaves the value of ptr unchanged, hence it still points to the same (now invalid) location, and not to the null pointer.

Parameters
ptr
Pointer to a memory block previously allocated with malloc, calloc or realloc to be deallocated.
If a null pointer is passed as argument, no action occurs.

Return Value
(none)

评分

参与人数 1威望 +1 收起 理由
ayb_ice + 1

查看全部评分

上官金虹 发表于 2011-10-26 09:08 | 显示全部楼层
C99 标准:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×

评分

参与人数 1威望 +1 收起 理由
ayb_ice + 1

查看全部评分

 楼主| ayb_ice 发表于 2011-10-26 09:46 | 显示全部楼层
感谢"上官金虹"
分数给你了,虽然少了点
sedatefire 发表于 2012-7-9 16:58 | 显示全部楼层
表示很困惑,51中使用free???
没有操作系统支持,跟谁去申请或释放内存啊
sedatefire 发表于 2012-7-9 16:59 | 显示全部楼层
即使是轻量级的ucos,也不支持malloc和free的
heap的设置我都是直接置零的
包括M3的堆设置,也是直接清0
您需要登录后才可以回帖 登录 | 注册

本版积分规则

222

主题

15494

帖子

34

粉丝
快速回复 在线客服 返回列表 返回顶部