1. 首页
  2. 数据库
  3. 其它
  4. 使用remalloc的注意事项说明(必看篇)

使用remalloc的注意事项说明(必看篇)

上传者: 2020-12-31 09:45:06上传 PDF文件 47.36KB 热度 12次

realloc returns a void pointer to the reallocated memory block. The return value is NULL if the size is zero and the buffer argument is not NULL, or if there is not enough available memory to expand the block to the given size. In the first case, the original block is freed. In the second, the original block is unchanged. The return value points to a storage space that is guaranteed to be suitably aligned for storage of any type of object. To get a pointer to a type other than void, use a type cast on the return value.这段E文基本上是在讲realloc()的返回值的。realloc()函数的返回值是void *型的。与第一种情况类似,如果发生了数据的移动,q指向了新分配的内存地址,而指针p还依然指向原先的内存地址,此时p成了野指针。

用户评论