Memory allocated not used unless initialized?

前端 未结 2 1664
无人共我
无人共我 2021-01-27 03:23

This is a followup to the question I just asked here.

I\'ve created a simple program to help myself understand memory allocation, malloc() and free()<

2条回答
  •  春和景丽
    2021-01-27 03:48

    it could be compiler optimization : the memory is not used at all, so a possible optimization is to not allocate this memory depening on compiler and on optimization options.

    i tested your code, the line : free((void *)pmeg); does not cause any memory leak for me.

提交回复
热议问题