且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

释放char数组时的内存泄漏

更新时间:2022-06-27 00:09:09

否.内存的内容对free()的工作方式没有影响.

No. the contents of the memory has no impact on how free() works.

free()不知道您将其用作以null终止的char字符串.永远不会在一块内存上使用strlen().

free() doesn't know you were using this as a null terminated char string. It would never use strlen() on a chunk of memory.

尝试使用valgrind之类的工具来检查代码是否泄漏.

Try a tool like valgrind to check your code for leaks.