==Updating==dom
Things that could result in a memory leak :debug
char ** arg = calloc(1, sizeof(char *)); arg[0] = calloc(10, sizeof(char)); arg[0] = NULL; free(arg); // MEMORY LEAK!
Rewriting to a freed memory block.code
In some weird cases, the programme will run smoothly for several steps (writing) and then throw a segmentation fault error.get
To save yourself some time from debugging memory leak issues, here are the things you can do:it
Always draw a diagram for the changes you made to the dynamically allocated blocksio
Attach debugging messages to each operation on the dynamically allocated blocks. Use debug flags.import
An ultimate wisdom:bug
The most important thing is to get it run with no error whatsoever, but not to do research on the cause of the problem.im
Therefore, if you have stuck for some time, re-write the piece of code -- rewriting always solves the problem.call