]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - progs/infocmp.c
ncurses 5.9 - patch 20120622
[ncurses.git] / progs / infocmp.c
index d57fa857f9879998dd5f49025ee7b97a00c7b04d..748c445585e3d451101e5fa9afb2e3afe8ddf707 100644 (file)
@@ -42,7 +42,7 @@
 
 #include <dump_entry.h>
 
-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