C Debugging Note

==Updating==


Memory leak issues:

  • Assigning NULL to a dynamically allocated memory block. Will not be freed later.
    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.

    In some weird cases, the programme will run smoothly for several steps (writing) and then throw a segmentation fault error.

  • Always draw a diagram for the changes you made.

猜你喜欢

转载自www.cnblogs.com/manqing/p/10448860.html
今日推荐