Cleanup xref table at exit of program (not after check), or when new file
authorPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 25 Aug 2002 11:21:14 +0000 (11:21 +0000)
committerPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 25 Aug 2002 11:21:14 +0000 (11:21 +0000)
is parsed.

gedcom/xref.c

index ea3e1fa7ded85cc6cbb8f445175e313aa606d489..1aa3b6c21347685b6312ca271ac7e3f29a721103 100644 (file)
@@ -83,8 +83,20 @@ struct xref_node *make_xref_node()
   return xr;
 }
 
+void cleanup_xrefs()
+{
+  hash_free(xrefs);
+  xrefs = NULL;
+}
+
 void make_xref_table()
 {
+  if (xrefs)
+    cleanup_xrefs();
+  else
+    /* Only register initially (if xrefs is still NULL) */
+    /* So that it is only registered once */
+    atexit(cleanup_xrefs);
   xrefs = hash_create(HASHCOUNT_T_MAX, NULL, NULL);
   hash_set_allocator(xrefs, xref_alloc, xref_free, NULL);
 }
@@ -111,7 +123,6 @@ int check_xref_table()
     }
   }
   
-  hash_free(xrefs);
   return result;
 }