X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom%2Fxref.c;h=1aa3b6c21347685b6312ca271ac7e3f29a721103;hb=2093bace026e3256acfc773db36a6cb2bd2bd058;hp=ea3e1fa7ded85cc6cbb8f445175e313aa606d489;hpb=9705cb493154688749e58b9c626e23973ddb49f7;p=gedcom-parse.git 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; }