X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fdemo_menus.c;h=dd1bd4fcbc31c11e60535a6ec465e7121e9a9c6f;hp=c19d02bb5451c1b170b7144da5fb1a1f3b8605af;hb=1385381954c39dc95558adc87fad457046959cc1;hpb=f367fa254ce3fe29710c86971f04e03111c2bd2c diff --git a/test/demo_menus.c b/test/demo_menus.c index c19d02bb..dd1bd4fc 100644 --- a/test/demo_menus.c +++ b/test/demo_menus.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_menus.c,v 1.33 2012/01/14 17:20:39 tom Exp $ + * $Id: demo_menus.c,v 1.37 2012/11/18 00:18:54 tom Exp $ * * Demonstrate a variety of functions from the menu library. * Thomas Dickey - 2005/4/9 @@ -109,18 +109,6 @@ static MENU *mpSelect; static bool loaded_file = FALSE; -#if !HAVE_STRDUP -#define strdup my_strdup -static char * -strdup(char *s) -{ - char *p = typeMalloc(char, strlen(s) + 1); - if (p) - strcpy(p, s); - return (p); -} -#endif /* not HAVE_STRDUP */ - /* Common function to allow ^T to toggle trace-mode in the middle of a test * so that trace-files can be made smaller. */ @@ -225,8 +213,8 @@ menu_create(ITEM ** items, int count, int ncols, MenuNo number) result = new_menu(items); if (has_colors()) { - set_menu_fore(result, COLOR_PAIR(1)); - set_menu_back(result, COLOR_PAIR(2)); + set_menu_fore(result, (chtype) COLOR_PAIR(1)); + set_menu_back(result, (chtype) COLOR_PAIR(2)); } set_menu_format(result, maxrow, maxcol); @@ -281,12 +269,15 @@ menu_destroy(MENU * m) free((char *) blob); } free(items); + items = 0; } #ifdef TRACE if ((count > 0) && (m == mpTrace)) { ITEM **ip = items; - while (*ip) - free(*ip++); + if (ip != 0) { + while (*ip) + free(*ip++); + } } #endif } @@ -398,6 +389,8 @@ build_select_menu(MenuNo number, char *filename) } loaded_file = TRUE; } + if (ap == 0) + free(items); } } if (ap == 0) { @@ -867,7 +860,7 @@ main(int argc, char *argv[]) #endif /* HAVE_RIPOFFLINE */ #ifdef TRACE case 't': - trace(strtoul(optarg, 0, 0)); + trace((unsigned) strtoul(optarg, 0, 0)); break; #endif default: