calloc: 4 bytes in 1 blocks are definitely lost

为君一笑 提交于 2019-12-24 07:26:23

问题


The following message gets generated after running my program under valgrind:

4 bytes in 1 blocks are definitely lost in loss record 1 of 11
==21938==    at 0x4C2DD10: calloc (vg_replace_malloc.c:623)
==21938==    by 0x401636: main (syntax.c:187)

That's the line of code where the leak was detected:

char *word = calloc(4, sizeof(char));   //syntax.c:187

I'm not understanding what's wrong with the code above. Why is valgrind generating an error?

来源:https://stackoverflow.com/questions/43967592/calloc-4-bytes-in-1-blocks-are-definitely-lost

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