Should I free memory before exit?

前端 未结 5 1025
闹比i
闹比i 2020-11-28 11:49

Should I free all my mallocated memory when I am exiting program in the due of error?

something = (char**) malloc (x * sizeof(char*));
for (i = 0; i < x;          


        
5条回答
  •  鱼传尺愫
    2020-11-28 12:18

    I had completely opposite scenario: segfaulting destructors of static objects from third-party library. Just because of explicitly freeing memory pools before exit. I believe, it is better to be reasonable and to concentrate on program structure.

提交回复
热议问题