X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fdemo_terminfo.c;h=ab1c22c425cfeb6d4452d4ad49e42fd68447068e;hp=5028e0ce9d863267923dbdcbb68fb871b71049e1;hb=31418a0e4a6f75ceffc9fee20ddbe390209a4ef4;hpb=5eb177874dea59107a1a2ea44f5d8f5bb99550b2;ds=sidebyside diff --git a/test/demo_terminfo.c b/test/demo_terminfo.c index 5028e0ce..ab1c22c4 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.48 2017/11/24 20:49:11 tom Exp $ * * A simple demo of the terminfo interface. */ @@ -69,8 +69,10 @@ static bool f_opt = FALSE; static bool n_opt = FALSE; static bool q_opt = FALSE; static bool s_opt = FALSE; +#ifdef NCURSES_VERSION static bool x_opt = FALSE; static bool y_opt = FALSE; +#endif static char *d_opt; static char *e_opt; @@ -152,7 +154,7 @@ next_dbitem(void) return result; } -#ifdef NO_LEAKS +#if NO_LEAKS static void free_dblist(void) { @@ -751,7 +753,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 +917,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); }