C free() routine and incremented array pointers

主宰稳场 提交于 2019-12-01 17:04:40

Absolutely not. The value passed to free() must be exactly the same value returned by malloc(). In fact, to ensure this is the case, I would recommend you use a copy of the pointer if you need a pointer you can increment or otherwise modify.

No

(And "Yes", you do need to "set it back".)

The API requires that you only pass to free() exactly what you got from malloc()1.


1. Or a null pointer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!