From: Peter Verthez Date: Sun, 25 Aug 2002 11:21:14 +0000 (+0000) Subject: Cleanup xref table at exit of program (not after check), or when new file X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=2093bace026e3256acfc773db36a6cb2bd2bd058;p=gedcom-parse.git Cleanup xref table at exit of program (not after check), or when new file is parsed. --- diff --git a/gedcom/xref.c b/gedcom/xref.c index ea3e1fa..1aa3b6c 100644 --- a/gedcom/xref.c +++ b/gedcom/xref.c @@ -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; }