X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fdemo_terminfo.c;h=7de1919e78a1953efd5220658c25870a83e1fc9a;hp=5028e0ce9d863267923dbdcbb68fb871b71049e1;hb=a924c24b2535cccdc0f5f991cd8ddcadcfa1f0d2;hpb=5eb177874dea59107a1a2ea44f5d8f5bb99550b2 diff --git a/test/demo_terminfo.c b/test/demo_terminfo.c index 5028e0ce..7de1919e 100644 --- a/test/demo_terminfo.c +++ b/test/demo_terminfo.c @@ -29,7 +29,7 @@ /* * Author: Thomas E. Dickey * - * $Id: demo_terminfo.c,v 1.45 2017/03/18 22:03:07 tom Exp $ + * $Id: demo_terminfo.c,v 1.47 2017/04/09 00:27:42 tom Exp $ * * A simple demo of the terminfo interface. */ @@ -152,7 +152,7 @@ next_dbitem(void) return result; } -#ifdef NO_LEAKS +#if NO_LEAKS static void free_dblist(void) { @@ -751,7 +751,18 @@ copy_code_list(NCURSES_CONST char *const *list) return result; } + +#if NO_LEAKS +static void +free_code_list(char **list) +{ + if (list) { + free(list[0]); + free(list); + } +} #endif +#endif /* USE_CODE_LISTS */ static void usage(void) @@ -904,17 +915,26 @@ main(int argc, char *argv[]) PLURAL(total_n_values), PLURAL(total_s_values)); -#ifdef NO_LEAKS +#if NO_LEAKS free_dblist(); - if (my_blob != 0) { - free(my_blob); - free(my_boolcodes); - free(my_numcodes); - free(my_numvalues); - free(my_strcodes); - free(my_strvalues); + if (input_name != 0) { + if (my_blob != 0) { + free(my_blob); + free(my_boolcodes); + free(my_numcodes); + free(my_numvalues); + free(my_strcodes); + free(my_strvalues); + } + } +#if USE_CODE_LISTS + else { + free_code_list(my_boolcodes); + free_code_list(my_numcodes); + free_code_list(my_strcodes); } #endif +#endif /* NO_LEAKS */ ExitProgram(EXIT_SUCCESS); }