X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=progs%2Finfocmp.c;h=748c445585e3d451101e5fa9afb2e3afe8ddf707;hp=d57fa857f9879998dd5f49025ee7b97a00c7b04d;hb=b6d0d9ad9e372e856f01a4c283cf784a15993903;hpb=ceaf3464e98d7984ed377f023abf63d69b7b8045 diff --git a/progs/infocmp.c b/progs/infocmp.c index d57fa857..748c4455 100644 --- a/progs/infocmp.c +++ b/progs/infocmp.c @@ -42,7 +42,7 @@ #include -MODULE_ID("$Id: infocmp.c,v 1.118 2012/05/26 21:11:32 tom Exp $") +MODULE_ID("$Id: infocmp.c,v 1.120 2012/06/08 23:05:25 tom Exp $") #define L_CURL "{" #define R_CURL "}" @@ -87,16 +87,34 @@ static int compare; static bool ignorepads; /* ignore pad prefixes when diffing */ #if NO_LEAKS + +typedef struct { + ENTRY *head; + ENTRY *tail; +} ENTERED; + +static ENTERED *entered; + #undef ExitProgram static void ExitProgram(int code) GCC_NORETURN; /* prototype is to get gcc to accept the noreturn attribute */ static void ExitProgram(int code) { - while (termcount-- > 0) - _nc_free_termtype(&entries[termcount].tterm); + int n; + + for (n = 0; n < termcount; ++n) { + ENTRY *new_head = _nc_head; + ENTRY *new_tail = _nc_tail; + _nc_head = entered[n].head; + _nc_tail = entered[n].tail; + _nc_free_entries(entered[n].head); + _nc_head = new_head; + _nc_tail = new_tail; + } _nc_leaks_dump_entry(); free(entries); + free(entered); _nc_free_tic(code); } #endif @@ -579,6 +597,7 @@ compare_predicate(PredType type, PredIdx idx, const char *name) case C_NAND: if (!e1->nuses) { + found = TRUE; for_each_entry() { e2 = &entries[extra++]; if (e2->nuses != e1->nuses) { @@ -959,6 +978,10 @@ file_comparison(int argc, char *argv[]) if (freopen(argv[n], "r", stdin) == 0) _nc_err_abort("Can't open %s", argv[n]); +#if NO_LEAKS + entered[n].head = _nc_head; + entered[n].tail = _nc_tail; +#endif _nc_head = _nc_tail = 0; /* parse entries out of the source file */ @@ -1654,6 +1677,9 @@ main(int argc, char *argv[]) tfile = typeMalloc(path, maxterms); tname = typeCalloc(char *, maxterms); entries = typeCalloc(ENTRY, maxterms); +#if NO_LEAKS + entered = typeCalloc(ENTERED, maxterms); +#endif if (tfile == 0 || tname == 0