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:
anthraxx 2014-06-10 23:14:29 +02:00
parent 76942f6933
commit 4a28a8debd

View file

@ -14,15 +14,18 @@ int main(void) {
/* read in password from standard input, exit on error. */ /* read in password from standard input, exit on error. */
if (getline(&input_line, &input_size, stdin) == -1) { if (getline(&input_line, &input_size, stdin) == -1) {
perror("Error"); perror("Error");
free(input_line);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* compare password, print info, exit appropriately */ /* compare password, print info, exit appropriately */
if (strcmp(input_line, password) == 0) { if (strcmp(input_line, password) == 0) {
puts("Success!"); puts("Success!");
free(input_line);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else { } else {
puts("How about no?!"); puts("How about no?!");
free(input_line);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }