Should I free memory before exit?
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; i++) something[i] = (char*) malloc (y + 1); ... if (anything == NULL) { printf("Your input is wrong!"); // should I free memory of every mallocated entity now? exit(1); } else { // work with mallocated entities ... free(something); // it must be here system("pause); } It depends on the OS. Best practice I'd say you should explicitly free it. It also makes using tools like valgrind a PITA if you have memory not freed all over the place and I