some manual (unnecessery) free for good manner
its not needed because OS is responsible to cleanup mem allocated by terminating process, but its still a good manner to explicitly free everything that gets allocated... yes this is "noise" if it terminates but neither does harm to feel being responsible to clean up everything ourselves. :) at least valgrind is silently happy :P :D
This commit is contained in:
parent
76942f6933
commit
4a28a8debd
|
@ -14,15 +14,18 @@ int main(void) {
|
|||
/* read in password from standard input, exit on error. */
|
||||
if (getline(&input_line, &input_size, stdin) == -1) {
|
||||
perror("Error");
|
||||
free(input_line);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* compare password, print info, exit appropriately */
|
||||
if (strcmp(input_line, password) == 0) {
|
||||
puts("Success!");
|
||||
free(input_line);
|
||||
exit(EXIT_SUCCESS);
|
||||
} else {
|
||||
puts("How about no?!");
|
||||
free(input_line);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue