Unlink xrefs properly when struct is deleted.
authorPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 12 Jan 2003 16:18:03 +0000 (16:18 +0000)
committerPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 12 Jan 2003 16:18:03 +0000 (16:18 +0000)
41 files changed:
gom/address.c
gom/address.h
gom/association.c
gom/association.h
gom/change_date.c
gom/change_date.h
gom/event.c
gom/event.h
gom/family.c
gom/family_link.c
gom/family_link.h
gom/func_template.h
gom/gom_internal.h
gom/gom_modify.c
gom/individual.c
gom/lds_event.c
gom/lds_event.h
gom/multimedia.c
gom/multimedia_link.c
gom/multimedia_link.h
gom/note.c
gom/note_sub.c
gom/note_sub.h
gom/personal_name.c
gom/personal_name.h
gom/place.c
gom/place.h
gom/repository.c
gom/source.c
gom/source_citation.c
gom/source_citation.h
gom/source_description.c
gom/source_description.h
gom/source_event.c
gom/source_event.h
gom/submission.c
gom/submitter.c
gom/user_rec.c
gom/user_rec.h
gom/user_ref.c
gom/user_ref.h

index fa8a3ee0a98eba2d3ae0aed727177984f8902186..b0d49a06f42cc556ae4326c92098c7c4fc37db56 100644 (file)
@@ -147,6 +147,13 @@ void address_subscribe()
   gedcom_subscribe_to_element(ELT_SUB_PHON, sub_phon_start, def_elt_end);
 }
 
   gedcom_subscribe_to_element(ELT_SUB_PHON, sub_phon_start, def_elt_end);
 }
 
+void UNREFALLFUNC(address)(struct address *address)
+{
+  if (address) {
+    UNREFALLFUNC(user_data)(address->extra);
+  }
+}
+
 void CLEANFUNC(address)(struct address *address)
 {
   if (address) {
 void CLEANFUNC(address)(struct address *address)
 {
   if (address) {
index 8c35b2eefd0204c56bb7ad6ce109882475ed3e6a..b738247208d3a0d9629d3d07425e57dab64b00c6 100644 (file)
@@ -31,6 +31,7 @@ int write_address(Gedcom_write_hndl hndl, int parent, struct address *address);
 
 DECLARE_SUB_MAKEFUNC(address);
 
 
 DECLARE_SUB_MAKEFUNC(address);
 
+DECLARE_UNREFALLFUNC(address);
 DECLARE_CLEANFUNC(address);
 DECLARE_ADDFUNC2(address, user_data);
 
 DECLARE_CLEANFUNC(address);
 DECLARE_ADDFUNC2(address, user_data);
 
index 2d9cc2d56fafd2faf3f2b9e7caf2244d765bb6f1..9398bbc49182929cb32efc2d7fe1cf536a825736 100644 (file)
@@ -97,6 +97,19 @@ void association_subscribe()
                              def_elt_end);
 }
 
                              def_elt_end);
 }
 
+void UNREFALLFUNC(association)(struct association *obj)
+{
+  if (obj) {
+    struct association* runner;
+    for (runner = obj; runner; runner = runner->next) {
+      unref_xref_value(runner->to);
+      UNREFALLFUNC(source_citation)(runner->citation);
+      UNREFALLFUNC(note_sub)(runner->note);
+      UNREFALLFUNC(user_data)(runner->extra);
+    }
+  }
+}
+
 void CLEANFUNC(association)(struct association* assoc)
 {
   if (assoc) {
 void CLEANFUNC(association)(struct association* assoc)
 {
   if (assoc) {
index 8c49023e074ff17942843723c2757ec09ff94fac..69d56fa6b4712e2ecd6bb67731480aa1acf251e9 100644 (file)
@@ -33,6 +33,7 @@ int write_associations(Gedcom_write_hndl hndl, int parent,
 
 DECLARE_SUB_MAKEFUNC(association);
 
 
 DECLARE_SUB_MAKEFUNC(association);
 
+DECLARE_UNREFALLFUNC(association);
 DECLARE_CLEANFUNC(association);
 DECLARE_ADDFUNC2(association, note_sub);
 DECLARE_ADDFUNC2(association, source_citation);
 DECLARE_CLEANFUNC(association);
 DECLARE_ADDFUNC2(association, note_sub);
 DECLARE_ADDFUNC2(association, source_citation);
index bf51134aa8be06e12b4986ae183394a575340ccb..14db8743abab7cd7180cfedea2f03664f9d94814 100644 (file)
@@ -92,6 +92,14 @@ void change_date_subscribe()
                              def_elt_end);
 }
 
                              def_elt_end);
 }
 
+void UNREFALLFUNC(change_date)(struct change_date* obj)
+{
+  if (obj) {
+    UNREFALLFUNC(note_sub)(obj->note);
+    UNREFALLFUNC(user_data)(obj->extra);
+  }
+}
+
 void CLEANFUNC(change_date)(struct change_date *chan)
 {
   if (chan) {
 void CLEANFUNC(change_date)(struct change_date *chan)
 {
   if (chan) {
index ac94b76791890991ee6a4508c984574289472a2c..f0022e49d49417d07b8d866480438194556a55ac 100644 (file)
@@ -32,6 +32,8 @@ int write_change_date(Gedcom_write_hndl hndl, int parent,
                      struct change_date *chan);
 
 DECLARE_SUB_MAKEFUNC(change_date);
                      struct change_date *chan);
 
 DECLARE_SUB_MAKEFUNC(change_date);
+
+DECLARE_UNREFALLFUNC(change_date);
 DECLARE_CLEANFUNC(change_date);
 DECLARE_ADDFUNC2(change_date, note_sub);
 DECLARE_ADDFUNC2(change_date, user_data);
 DECLARE_CLEANFUNC(change_date);
 DECLARE_ADDFUNC2(change_date, note_sub);
 DECLARE_ADDFUNC2(change_date, user_data);
index af6e9129c11ea417c23de76f6e744946db4dec2e..b946aa64a2f069f44ca817fc9e6c36578c62b59d 100644 (file)
@@ -222,6 +222,22 @@ void event_subscribe()
                              sub_evt_caus_start, def_elt_end);
 }
 
                              sub_evt_caus_start, def_elt_end);
 }
 
+void UNREFALLFUNC(event)(struct event* obj)
+{
+  if (obj) {
+    struct event* runner;
+    for (runner = obj; runner; runner = runner->next) {
+      UNREFALLFUNC(place)(runner->place);
+      UNREFALLFUNC(address)(runner->address);
+      UNREFALLFUNC(source_citation)(runner->citation);
+      UNREFALLFUNC(multimedia_link)(runner->mm_link);
+      UNREFALLFUNC(note_sub)(runner->note);
+      unref_xref_value(runner->family);
+      UNREFALLFUNC(user_data)(runner->extra);
+    }
+  }
+}
+
 void CLEANFUNC(event)(struct event* evt)
 {
   if (evt) {
 void CLEANFUNC(event)(struct event* evt)
 {
   if (evt) {
index aa519cbda0f14fc8bb08e757b047ef7cfcca0409..65fa9671cd36d6da60f36e793094fa1c2d957966 100644 (file)
@@ -39,6 +39,7 @@ int write_events(Gedcom_write_hndl hndl, int parent, EventType evt_type,
 
 DECLARE_SUB_MAKEFUNC(event);
 
 
 DECLARE_SUB_MAKEFUNC(event);
 
+DECLARE_UNREFALLFUNC(event);
 DECLARE_CLEANFUNC(event);
 DECLARE_ADDFUNC2(event, source_citation);
 DECLARE_ADDFUNC2(event, multimedia_link);
 DECLARE_CLEANFUNC(event);
 DECLARE_ADDFUNC2(event, source_citation);
 DECLARE_ADDFUNC2(event, multimedia_link);
index 8389569c0a93418e79d775762afc94569a19df4e..9d4a4e562f5c46822409dcb24f9a09af06580646 100644 (file)
@@ -73,6 +73,24 @@ void family_subscribe()
   gedcom_subscribe_to_element(ELT_FAM_SUBM, fam_subm_start, def_elt_end);
 }
 
   gedcom_subscribe_to_element(ELT_FAM_SUBM, fam_subm_start, def_elt_end);
 }
 
+void UNREFALLFUNC(family)(struct family *fam)
+{
+  if (fam) {
+    UNREFALLFUNC(event)(fam->event);
+    unref_xref_value(fam->husband);
+    unref_xref_value(fam->wife);
+    UNREFALLFUNC(xref_list)(fam->children);
+    UNREFALLFUNC(xref_list)(fam->submitters);
+    UNREFALLFUNC(lds_event)(fam->lds_spouse_sealing);
+    UNREFALLFUNC(source_citation)(fam->citation);
+    UNREFALLFUNC(multimedia_link)(fam->mm_link);
+    UNREFALLFUNC(note_sub)(fam->note);
+    UNREFALLFUNC(user_ref_number)(fam->ref);
+    UNREFALLFUNC(change_date)(fam->change_date);
+    UNREFALLFUNC(user_data)(fam->extra);
+  }
+}
+
 void CLEANFUNC(family)(struct family* fam)
 {
   if (fam) {
 void CLEANFUNC(family)(struct family* fam)
 {
   if (fam) {
index cb266b209d25e03621cc217549140f457720ded2..cb5435be90781d1f18c3726236479e3da24319de 100644 (file)
@@ -98,6 +98,16 @@ void family_link_subscribe()
                              def_elt_end);
 }
 
                              def_elt_end);
 }
 
+void UNREFALLFUNC(pedigree)(struct pedigree* obj)
+{
+  if (obj) {
+    struct pedigree* runner;
+    for (runner = obj; runner; runner = runner->next) {
+      UNREFALLFUNC(user_data)(runner->extra);
+    }
+  }
+}
+
 void CLEANFUNC(pedigree)(struct pedigree* ped)
 {
   if (ped) {
 void CLEANFUNC(pedigree)(struct pedigree* ped)
 {
   if (ped) {
@@ -105,6 +115,19 @@ void CLEANFUNC(pedigree)(struct pedigree* ped)
   }
 }
 
   }
 }
 
+void UNREFALLFUNC(family_link)(struct family_link* obj)
+{
+  if (obj) {
+    struct family_link* runner;
+    for (runner = obj; runner; runner = runner->next) {
+      unref_xref_value(runner->family);
+      UNREFALLFUNC(pedigree)(runner->pedigree);
+      UNREFALLFUNC(note_sub)(runner->note);
+      UNREFALLFUNC(user_data)(runner->extra);
+    }
+  }
+}
+
 void CLEANFUNC(family_link)(struct family_link *link)
 {
   if (link) {
 void CLEANFUNC(family_link)(struct family_link *link)
 {
   if (link) {
index eeb6cd99e7265d00c006c5667d57bf497dd6af71..bce305f1c10b91b7597f146e147326bdec95c8ee 100644 (file)
@@ -38,6 +38,7 @@ int write_family_links(Gedcom_write_hndl hndl, int parent, LinkType type,
 
 DECLARE_SUB_MAKEFUNC(family_link);
 
 
 DECLARE_SUB_MAKEFUNC(family_link);
 
+DECLARE_UNREFALLFUNC(family_link);
 DECLARE_CLEANFUNC(family_link);
 DECLARE_ADDFUNC2(family_link, note_sub);
 DECLARE_ADDFUNC2(family_link, user_data);
 DECLARE_CLEANFUNC(family_link);
 DECLARE_ADDFUNC2(family_link, note_sub);
 DECLARE_ADDFUNC2(family_link, user_data);
index a21424d1b425b1847d3f2123b556da5a0758671d..872f0ada855fa2b43135b2706cb94ce38cce530a 100644 (file)
@@ -31,6 +31,7 @@
 #define CLEANFUNC(STRUCTTYPE)    STRUCTTYPE ## _cleanup
 #define ADDFUNC(STRUCTTYPE)      gom_add_ ## STRUCTTYPE
 #define SUB_ADDFUNC(STRUCTTYPE)  gom_add_ ## STRUCTTYPE
 #define CLEANFUNC(STRUCTTYPE)    STRUCTTYPE ## _cleanup
 #define ADDFUNC(STRUCTTYPE)      gom_add_ ## STRUCTTYPE
 #define SUB_ADDFUNC(STRUCTTYPE)  gom_add_ ## STRUCTTYPE
+#define UNREFALLFUNC(STRUCTTYPE) STRUCTTYPE ## _unref_all
 #define DELETEFUNC(STRUCTTYPE)   gom_delete_ ## STRUCTTYPE
 #define SUB_DELETEFUNC(STRUCTTYPE) gom_delete_ ## STRUCTTYPE
 #define ADDFUNC2(T1,T2)          T1 ## _add_ ## T2
 #define DELETEFUNC(STRUCTTYPE)   gom_delete_ ## STRUCTTYPE
 #define SUB_DELETEFUNC(STRUCTTYPE) gom_delete_ ## STRUCTTYPE
 #define ADDFUNC2(T1,T2)          T1 ## _add_ ## T2
@@ -48,6 +49,9 @@
 #define DECLARE_CLEANFUNC(STRUCTTYPE)                                         \
   void CLEANFUNC(STRUCTTYPE)(struct STRUCTTYPE* obj)
 
 #define DECLARE_CLEANFUNC(STRUCTTYPE)                                         \
   void CLEANFUNC(STRUCTTYPE)(struct STRUCTTYPE* obj)
 
+#define DECLARE_UNREFALLFUNC(STRUCTTYPE)                                      \
+  void UNREFALLFUNC(STRUCTTYPE)(struct STRUCTTYPE* obj)
+
 #define DECLARE_ADDFUNC2(STRUCTTYPE,T2)                                       \
   void ADDFUNC2(STRUCTTYPE,T2)(Gom_ctxt ctxt, struct T2* obj)
 
 #define DECLARE_ADDFUNC2(STRUCTTYPE,T2)                                       \
   void ADDFUNC2(STRUCTTYPE,T2)(Gom_ctxt ctxt, struct T2* obj)
 
   }
 
 #define DEFINE_DESTROYFUNC(STRUCTTYPE,FIRSTVAL)                               \
   }
 
 #define DEFINE_DESTROYFUNC(STRUCTTYPE,FIRSTVAL)                               \
-  void CLEANFUNC(STRUCTTYPE)(struct STRUCTTYPE* obj);                         \
+  DECLARE_CLEANFUNC(STRUCTTYPE);                                              \
   void DESTROYFUNC(STRUCTTYPE)(struct STRUCTTYPE* obj) {                      \
     if (obj) {                                                                \
       CLEANFUNC(STRUCTTYPE)(obj);                                             \
   void DESTROYFUNC(STRUCTTYPE)(struct STRUCTTYPE* obj) {                      \
     if (obj) {                                                                \
       CLEANFUNC(STRUCTTYPE)(obj);                                             \
     return obj;                                                               \
   }
 
     return obj;                                                               \
   }
 
-/* TODO: Check whether there are still xrefs linked in */
 #define DEFINE_DELETEFUNC(STRUCTTYPE)                                         \
 #define DEFINE_DELETEFUNC(STRUCTTYPE)                                         \
+  DECLARE_UNREFALLFUNC(STRUCTTYPE);                                           \
   int DELETEFUNC(STRUCTTYPE)(struct STRUCTTYPE* obj)                          \
   {                                                                           \
     int result = 1;                                                           \
     if (obj) {                                                                \
       result = gedcom_delete_xref(obj->xrefstr);                              \
   int DELETEFUNC(STRUCTTYPE)(struct STRUCTTYPE* obj)                          \
   {                                                                           \
     int result = 1;                                                           \
     if (obj) {                                                                \
       result = gedcom_delete_xref(obj->xrefstr);                              \
-      if (result == 0)                                                        \
+      if (result == 0) {                                                      \
+        UNREFALLFUNC(STRUCTTYPE)(obj);                                        \
        DESTROYFUNC(STRUCTTYPE)(obj);                                         \
        DESTROYFUNC(STRUCTTYPE)(obj);                                         \
+      }                                                                       \
     }                                                                         \
     return result;                                                            \
   }
     }                                                                         \
     return result;                                                            \
   }
   {                                                                           \
     int result = 1;                                                           \
     if (obj && *obj) {                                                        \
   {                                                                           \
     int result = 1;                                                           \
     if (obj && *obj) {                                                        \
+      UNREFALLFUNC(STRUCTTYPE)(*obj);                                         \
       CLEANFUNC(STRUCTTYPE)(*obj);                                            \
       SAFE_FREE(*obj);                                                        \
       result = 0;                                                             \
       CLEANFUNC(STRUCTTYPE)(*obj);                                            \
       SAFE_FREE(*obj);                                                        \
       result = 0;                                                             \
index 910e1569bf004689c59ee08d305b776e095ac67c..1def3f9ee15835bef2655033ffba331047866ec6 100644 (file)
@@ -76,6 +76,7 @@ void gom_cast_error(const char* file, int line,
 void gom_no_context(const char* file, int line);
 void gom_unexpected_context(const char* file, int line, OBJ_TYPE found);
 void gom_xref_already_in_use(const char *xrefstr);
 void gom_no_context(const char* file, int line);
 void gom_unexpected_context(const char* file, int line, OBJ_TYPE found);
 void gom_xref_already_in_use(const char *xrefstr);
+void unref_xref_value(struct xref_value *xref);
 
 int gom_write_xref_list(Gedcom_write_hndl hndl,
                        Gedcom_elt elt, int tag, int parent_rec_or_elt,
 
 int gom_write_xref_list(Gedcom_write_hndl hndl,
                        Gedcom_elt elt, int tag, int parent_rec_or_elt,
@@ -118,6 +119,7 @@ void NULL_DESTROY(void* anything);
 
 #include "func_template.h"
 
 
 #include "func_template.h"
 
+DECLARE_UNREFALLFUNC(xref_list);
 DECLARE_CLEANFUNC(xref_list);
   
 #endif /* __GOM_INTERNAL_H */
 DECLARE_CLEANFUNC(xref_list);
   
 #endif /* __GOM_INTERNAL_H */
index b876a9e5cfa2790ff825a629ceec8b915a6c7ccf..11db4d775d5c5be0be9e49c0e995bb772b324846 100644 (file)
@@ -79,6 +79,23 @@ char* gom_set_string_for_locale(char** data, const char* locale_str)
   return result;
 }
 
   return result;
 }
 
+void unref_xref_value(struct xref_value *xref)
+{
+  if (xref)
+    gedcom_unlink_xref(xref->type, xref->string);
+}
+
+void UNREFALLFUNC(xref_list)(struct xref_list* obj)
+{
+  if (obj) {
+    struct xref_list* runner;
+    for (runner = obj; runner; runner = runner->next) {
+      unref_xref_value(runner->xref);
+      UNREFALLFUNC(user_data)(runner->extra);
+    }
+  }
+}
+
 void CLEANFUNC(xref_list)(struct xref_list *obj)
 {
   if (obj) {
 void CLEANFUNC(xref_list)(struct xref_list *obj)
 {
   if (obj) {
index 103ad31216ccb77d7fc4928041fa2d2fc200a36a..b9652ef87ca28e557bb3a464059af1ec0b217f94 100644 (file)
@@ -102,6 +102,29 @@ void individual_add_family_link(Gom_ctxt ctxt, int ctxt_type,
   }
 }
 
   }
 }
 
+void UNREFALLFUNC(individual)(struct individual *obj)
+{
+  if (obj) {
+    UNREFALLFUNC(personal_name)(obj->name);
+    UNREFALLFUNC(event)(obj->event);
+    UNREFALLFUNC(event)(obj->attribute);
+    UNREFALLFUNC(lds_event)(obj->lds_individual_ordinance);
+    UNREFALLFUNC(family_link)(obj->child_to_family);
+    UNREFALLFUNC(family_link)(obj->spouse_to_family);
+    UNREFALLFUNC(xref_list)(obj->submitters);
+    UNREFALLFUNC(association)(obj->association);
+    UNREFALLFUNC(xref_list)(obj->alias);
+    UNREFALLFUNC(xref_list)(obj->ancestor_interest);
+    UNREFALLFUNC(xref_list)(obj->descendant_interest);
+    UNREFALLFUNC(source_citation)(obj->citation);
+    UNREFALLFUNC(multimedia_link)(obj->mm_link);
+    UNREFALLFUNC(note_sub)(obj->note);
+    UNREFALLFUNC(user_ref_number)(obj->ref);
+    UNREFALLFUNC(change_date)(obj->change_date);
+    UNREFALLFUNC(user_data)(obj->extra);
+  }
+}
+
 void CLEANFUNC(individual)(struct individual* indiv)
 {
   if (indiv) {
 void CLEANFUNC(individual)(struct individual* indiv)
 {
   if (indiv) {
index 8587b11acbea0a5218b3e6d6276f57db3a3aa38c..6a7be358df5267a88948c5eeeae7399800b8f73a 100644 (file)
@@ -106,6 +106,19 @@ void lds_event_subscribe()
                              sub_lds_event_famc_start, def_elt_end);
 }
 
                              sub_lds_event_famc_start, def_elt_end);
 }
 
+void UNREFALLFUNC(lds_event)(struct lds_event* obj)
+{
+  if (obj) {
+    struct lds_event* runner;
+    for (runner = obj; runner; runner = runner->next) {
+      unref_xref_value(runner->family);
+      UNREFALLFUNC(source_citation)(runner->citation);
+      UNREFALLFUNC(note_sub)(runner->note);
+      UNREFALLFUNC(user_data)(runner->extra);
+    }
+  }
+}
+
 void CLEANFUNC(lds_event)(struct lds_event* lds)
 {
   if (lds) {
 void CLEANFUNC(lds_event)(struct lds_event* lds)
 {
   if (lds) {
index f49e2eea678bfe996ba17eae0586c3281886190a..68eb4863a20484b8e04a7f3cdeb23d48c49d39ee 100644 (file)
@@ -34,6 +34,7 @@ int write_lds_events(Gedcom_write_hndl hndl, int parent,
 
 DECLARE_SUB_MAKEFUNC(lds_event);
 
 
 DECLARE_SUB_MAKEFUNC(lds_event);
 
+DECLARE_UNREFALLFUNC(lds_event);
 DECLARE_CLEANFUNC(lds_event);
 DECLARE_ADDFUNC2(lds_event, note_sub);
 DECLARE_ADDFUNC2(lds_event, source_citation);
 DECLARE_CLEANFUNC(lds_event);
 DECLARE_ADDFUNC2(lds_event, note_sub);
 DECLARE_ADDFUNC2(lds_event, source_citation);
index 38ffa3ff6f8973ad04b30bdcc8a7e78cdc61b636..9dbf90b5ee390d22015181cc7b534a05cfc14ac8 100644 (file)
@@ -77,6 +77,17 @@ void multimedia_subscribe()
   gedcom_subscribe_to_element(ELT_OBJE_OBJE, obje_obje_start, def_elt_end);
 }
 
   gedcom_subscribe_to_element(ELT_OBJE_OBJE, obje_obje_start, def_elt_end);
 }
 
+void UNREFALLFUNC(multimedia)(struct multimedia *obj)
+{
+  if (obj) {
+    UNREFALLFUNC(note_sub)(obj->note);
+    unref_xref_value(obj->continued);
+    UNREFALLFUNC(user_ref_number)(obj->ref);
+    UNREFALLFUNC(change_date)(obj->change_date);
+    UNREFALLFUNC(user_data)(obj->extra);
+  }
+}
+
 void CLEANFUNC(multimedia)(struct multimedia* obj)
 {
   if (obj) {
 void CLEANFUNC(multimedia)(struct multimedia* obj)
 {
   if (obj) {
index 0b1c4eb85de6c9a00adfebbf8b727c600d63f297..44e9a2df79d6afec7bcabc99eeb2f827fdb93d46 100644 (file)
@@ -100,6 +100,18 @@ void multimedia_link_subscribe()
                              sub_obje_file_start, def_elt_end);
 }
 
                              sub_obje_file_start, def_elt_end);
 }
 
+void UNREFALLFUNC(multimedia_link)(struct multimedia_link* obj)
+{
+  if (obj) {
+    struct multimedia_link* runner;
+    for (runner = obj; runner; runner = runner->next) {
+      unref_xref_value(runner->reference);
+      UNREFALLFUNC(note_sub)(runner->note);
+      UNREFALLFUNC(user_data)(runner->extra);
+    }
+  }
+}
+
 void CLEANFUNC(multimedia_link)(struct multimedia_link* mm)
 {
   if (mm) {
 void CLEANFUNC(multimedia_link)(struct multimedia_link* mm)
 {
   if (mm) {
index 9503449957840a14fec7bc50978b77edfd7e05a1..ec2ec6d3422969eefe1de29c76ff4829c762c844 100644 (file)
@@ -34,6 +34,7 @@ int write_multimedia_links(Gedcom_write_hndl hndl, int parent,
 
 DECLARE_SUB_MAKEFUNC(multimedia_link);
 
 
 DECLARE_SUB_MAKEFUNC(multimedia_link);
 
+DECLARE_UNREFALLFUNC(multimedia_link);
 DECLARE_CLEANFUNC(multimedia_link);
 DECLARE_ADDFUNC2(multimedia_link, note_sub);
 DECLARE_ADDFUNC2(multimedia_link, user_data);
 DECLARE_CLEANFUNC(multimedia_link);
 DECLARE_ADDFUNC2(multimedia_link, note_sub);
 DECLARE_ADDFUNC2(multimedia_link, user_data);
index 3c8bc69f7095fa1f72c67c67b013b056e194d8f2..6d0dc8aa32ec7909dca13b3837199a86994c5408 100644 (file)
@@ -85,6 +85,16 @@ void note_subscribe()
   gedcom_subscribe_to_element(ELT_SUB_CONC, sub_cont_conc_start, def_elt_end);
 }
 
   gedcom_subscribe_to_element(ELT_SUB_CONC, sub_cont_conc_start, def_elt_end);
 }
 
+void UNREFALLFUNC(note)(struct note *obj)
+{
+  if (obj) {
+    UNREFALLFUNC(source_citation)(obj->citation);
+    UNREFALLFUNC(user_ref_number)(obj->ref);
+    UNREFALLFUNC(change_date)(obj->change_date);
+    UNREFALLFUNC(user_data)(obj->extra);
+  }
+}
+
 void CLEANFUNC(note)(struct note* note)
 {
   if (note) {
 void CLEANFUNC(note)(struct note* note)
 {
   if (note) {
index 2d748a6017ee8be6f77339d3cbbefcbf39889aaf..2ff76db751e6eca2b62c999a446037e6e877d837 100644 (file)
@@ -122,6 +122,18 @@ void note_sub_subscribe()
   gedcom_subscribe_to_element(ELT_SUB_NOTE, sub_note_start, sub_note_end);
 }
 
   gedcom_subscribe_to_element(ELT_SUB_NOTE, sub_note_start, sub_note_end);
 }
 
+void UNREFALLFUNC(note_sub)(struct note_sub* obj)
+{
+  if (obj) {
+    struct note_sub* runner;
+    for (runner = obj; runner; runner = runner->next) {
+      unref_xref_value(runner->reference);
+      UNREFALLFUNC(source_citation)(runner->citation);
+      UNREFALLFUNC(user_data)(runner->extra);
+    }
+  }
+}
+
 void CLEANFUNC(note_sub)(struct note_sub* note)
 {
   if (note) {
 void CLEANFUNC(note_sub)(struct note_sub* note)
 {
   if (note) {
index c78bfa2e11359a3558cf3d8f7ed778a21170b47f..f47060e71801a21da5ad99734b86f3612c8a0946 100644 (file)
@@ -32,6 +32,7 @@ int write_note_subs(Gedcom_write_hndl hndl, int parent, struct note_sub* note);
 
 DECLARE_SUB_MAKEFUNC(note_sub);
 
 
 DECLARE_SUB_MAKEFUNC(note_sub);
 
+DECLARE_UNREFALLFUNC(note_sub);
 DECLARE_CLEANFUNC(note_sub);
 DECLARE_ADDFUNC2(note_sub, source_citation);
 DECLARE_ADDFUNC2(note_sub, user_data);
 DECLARE_CLEANFUNC(note_sub);
 DECLARE_ADDFUNC2(note_sub, source_citation);
 DECLARE_ADDFUNC2(note_sub, user_data);
index 3b6bb8ea4c657e38b2e557aa5c5dd6e7507c7a7b..18f3efbb3e134fdfadd7ec6dd99cf09822d61285 100644 (file)
@@ -91,6 +91,18 @@ void name_subscribe()
                              def_elt_end);
 }
 
                              def_elt_end);
 }
 
+void UNREFALLFUNC(personal_name)(struct personal_name* obj)
+{
+  if (obj) {
+    struct personal_name* runner;
+    for (runner = obj; runner; runner = runner->next) {
+      UNREFALLFUNC(source_citation)(runner->citation);
+      UNREFALLFUNC(note_sub)(runner->note);
+      UNREFALLFUNC(user_data)(runner->extra);
+    }
+  }
+}
+
 void CLEANFUNC(personal_name)(struct personal_name* name)
 {
   if (name) {
 void CLEANFUNC(personal_name)(struct personal_name* name)
 {
   if (name) {
index 24ce27d55a0b2c76bf70009a9e4891be9a7be7f1..c8e76615496807f70fbc47e3f035753899175960 100644 (file)
@@ -32,6 +32,8 @@ int write_names(Gedcom_write_hndl hndl, int parent,
                struct personal_name *name);
 
 DECLARE_SUB_MAKEFUNC(personal_name);
                struct personal_name *name);
 
 DECLARE_SUB_MAKEFUNC(personal_name);
+
+DECLARE_UNREFALLFUNC(personal_name);
 DECLARE_CLEANFUNC(personal_name);
 DECLARE_ADDFUNC2(personal_name, source_citation);
 DECLARE_ADDFUNC2(personal_name, note_sub);
 DECLARE_CLEANFUNC(personal_name);
 DECLARE_ADDFUNC2(personal_name, source_citation);
 DECLARE_ADDFUNC2(personal_name, note_sub);
index cb852536aec106632f8da69e0c1a27f354b5c53a..371e2e311dc84055c647ddc1b14bb5192e021cc3 100644 (file)
@@ -88,6 +88,15 @@ void place_subscribe()
                              sub_place_form_start, def_elt_end);
 }
 
                              sub_place_form_start, def_elt_end);
 }
 
+void UNREFALLFUNC(place)(struct place* obj)
+{
+  if (obj) {
+    UNREFALLFUNC(source_citation)(obj->citation);
+    UNREFALLFUNC(note_sub)(obj->note);
+    UNREFALLFUNC(user_data)(obj->extra);
+  }
+}
+
 void CLEANFUNC(place)(struct place* place)
 {
   if (place) {
 void CLEANFUNC(place)(struct place* place)
 {
   if (place) {
index 614dacb3fc08733ace090dbbb71f3cd7507a494c..e73d924ab304cf47928a6bb7ecef47c9aeabd3a9 100644 (file)
@@ -32,6 +32,7 @@ int write_place(Gedcom_write_hndl hndl, int parent, struct place* place);
 
 DECLARE_SUB_MAKEFUNC(place);
 
 
 DECLARE_SUB_MAKEFUNC(place);
 
+DECLARE_UNREFALLFUNC(place);
 DECLARE_CLEANFUNC(place);
 DECLARE_ADDFUNC2(place, source_citation);
 DECLARE_ADDFUNC2(place, note_sub);
 DECLARE_CLEANFUNC(place);
 DECLARE_ADDFUNC2(place, source_citation);
 DECLARE_ADDFUNC2(place, note_sub);
index 9d383fa6347f1297592ef48f0ffec6c7dff2c919..57c6f2889dd5fd5cc8dd9c7a072da904ec71e137 100644 (file)
@@ -58,6 +58,17 @@ void repository_subscribe()
   gedcom_subscribe_to_element(ELT_REPO_NAME, repo_name_start, def_elt_end);
 }
 
   gedcom_subscribe_to_element(ELT_REPO_NAME, repo_name_start, def_elt_end);
 }
 
+void UNREFALLFUNC(repository)(struct repository *obj)
+{
+  if (obj) {
+    UNREFALLFUNC(address)(obj->address);
+    UNREFALLFUNC(note_sub)(obj->note);
+    UNREFALLFUNC(user_ref_number)(obj->ref);
+    UNREFALLFUNC(change_date)(obj->change_date);
+    UNREFALLFUNC(user_data)(obj->extra);
+  }
+}
+
 void CLEANFUNC(repository)(struct repository* repo)
 {
   if (repo) {
 void CLEANFUNC(repository)(struct repository* repo)
 {
   if (repo) {
index c13acb38f0edab45392c4f64b01411d014c42309..51c0335443c64d1cce9f470f1e2e500c644768fb 100644 (file)
@@ -95,6 +95,22 @@ void source_add_note_to_repo(Gom_ctxt ctxt, struct note_sub* note)
     LINK_CHAIN_ELT(note_sub, sour->repository.note, note);  
 }
 
     LINK_CHAIN_ELT(note_sub, sour->repository.note, note);  
 }
 
+void UNREFALLFUNC(source)(struct source *obj)
+{
+  if (obj) {
+    UNREFALLFUNC(source_event)(obj->data.event);
+    UNREFALLFUNC(note_sub)(obj->data.note);
+    unref_xref_value(obj->repository.link);
+    UNREFALLFUNC(note_sub)(obj->repository.note);
+    UNREFALLFUNC(source_description)(obj->repository.description);
+    UNREFALLFUNC(multimedia_link)(obj->mm_link);
+    UNREFALLFUNC(note_sub)(obj->note);
+    UNREFALLFUNC(user_ref_number)(obj->ref);
+    UNREFALLFUNC(change_date)(obj->change_date);
+    UNREFALLFUNC(user_data)(obj->extra);
+  }
+}
+
 void CLEANFUNC(source)(struct source* sour)
 {
   if (sour) {
 void CLEANFUNC(source)(struct source* sour)
 {
   if (sour) {
index c79efcce1ce97c94cb92647fcb11047ae3ce87aa..64ad42b4e7bb34ee1331bdc8424185155c4fe2cb 100644 (file)
@@ -166,6 +166,15 @@ void citation_subscribe()
                              def_elt_end);
 }
 
                              def_elt_end);
 }
 
+void UNREFALLFUNC(text)(struct text* obj)
+{
+  if (obj) {
+    struct text* runner;
+    for (runner = obj; runner; runner = runner->next)
+      UNREFALLFUNC(user_data)(runner->extra);
+  }
+}
+
 void CLEANFUNC(text)(struct text* t)
 {
   if (t) {
 void CLEANFUNC(text)(struct text* t)
 {
   if (t) {
@@ -173,6 +182,20 @@ void CLEANFUNC(text)(struct text* t)
   }
 }
 
   }
 }
 
+void UNREFALLFUNC(source_citation)(struct source_citation* obj)
+{
+  if (obj) {
+    struct source_citation* runner;
+    for (runner = obj; runner; runner = runner->next) {
+      unref_xref_value(runner->reference);
+      UNREFALLFUNC(text)(runner->text);
+      UNREFALLFUNC(multimedia_link)(runner->mm_link);
+      UNREFALLFUNC(note_sub)(runner->note);
+      UNREFALLFUNC(user_data)(runner->extra);
+    }
+  }
+}
+
 void CLEANFUNC(source_citation)(struct source_citation* cit)
 {
   if (cit) {
 void CLEANFUNC(source_citation)(struct source_citation* cit)
 {
   if (cit) {
index 0689551bbf36ff28cffe2ca4dc2ef17bec595898..21fb52f649fd5d18563c435eb1ef1f27e732e207 100644 (file)
@@ -34,6 +34,7 @@ int write_citations(Gedcom_write_hndl hndl, int parent,
 
 DECLARE_SUB_MAKEFUNC(source_citation);
 
 
 DECLARE_SUB_MAKEFUNC(source_citation);
 
+DECLARE_UNREFALLFUNC(source_citation);
 DECLARE_CLEANFUNC(source_citation);
 DECLARE_ADDFUNC2(source_citation, note_sub);
 DECLARE_ADDFUNC2(source_citation, multimedia_link);
 DECLARE_CLEANFUNC(source_citation);
 DECLARE_ADDFUNC2(source_citation, note_sub);
 DECLARE_ADDFUNC2(source_citation, multimedia_link);
index 87f34abad7390f04267f583dde6e78b0534b8fc3..71bd9e816db3a73c3357748ce8eb520f3345d2ca 100644 (file)
@@ -75,6 +75,16 @@ void source_description_subscribe()
                              sub_sour_caln_medi_start, def_elt_end);
 }
 
                              sub_sour_caln_medi_start, def_elt_end);
 }
 
+void UNREFALLFUNC(source_description)(struct source_description* obj)
+{
+  if (obj) {
+    struct source_description* runner;
+    for (runner = obj; runner; runner = runner->next) {
+      UNREFALLFUNC(user_data)(runner->extra);
+    }
+  }
+}
+
 void CLEANFUNC(source_description)(struct source_description* desc)
 {
   if (desc) {
 void CLEANFUNC(source_description)(struct source_description* desc)
 {
   if (desc) {
index 1ff5441764ee85cd70990a9f1f17d9bd9ba25661..ce1802f8d3f00d91192391b9069328e5f393b090 100644 (file)
@@ -34,6 +34,7 @@ int write_source_descriptions(Gedcom_write_hndl hndl, int parent,
 
 DECLARE_SUB_MAKEFUNC(source_description);
 
 
 DECLARE_SUB_MAKEFUNC(source_description);
 
+DECLARE_UNREFALLFUNC(source_description);
 DECLARE_CLEANFUNC(source_description);
 DECLARE_ADDFUNC2(source_description, user_data);
 
 DECLARE_CLEANFUNC(source_description);
 DECLARE_ADDFUNC2(source_description, user_data);
 
index 02882dc113c024250bb5b7f1702beb010ad2efb8..6e353b962b587548095f716020b522be011b3e2c 100644 (file)
@@ -78,6 +78,16 @@ void source_event_subscribe()
                              sub_sour_even_plac_start, def_elt_end);
 }
 
                              sub_sour_even_plac_start, def_elt_end);
 }
 
+void UNREFALLFUNC(source_event)(struct source_event* obj)
+{
+  if (obj) {
+    struct source_event* runner;
+    for (runner = obj; runner; runner = runner->next) {
+      UNREFALLFUNC(user_data)(runner->extra);
+    }
+  }
+}
+
 void CLEANFUNC(source_event)(struct source_event* evt)
 {
   if (evt) {
 void CLEANFUNC(source_event)(struct source_event* evt)
 {
   if (evt) {
index 7d86a6e3370f3af508c02f4578236b1063c1e845..549281c16bff606daecd2d80c5a1fa07e4f9cb97 100644 (file)
@@ -33,6 +33,7 @@ int write_source_events(Gedcom_write_hndl hndl, int parent,
 
 DECLARE_SUB_MAKEFUNC(source_event);
 
 
 DECLARE_SUB_MAKEFUNC(source_event);
 
+DECLARE_UNREFALLFUNC(source_event);
 DECLARE_CLEANFUNC(source_event);
 DECLARE_ADDFUNC2(source_event, user_data);
 
 DECLARE_CLEANFUNC(source_event);
 DECLARE_ADDFUNC2(source_event, user_data);
 
index 3ecee29232686349a6d31381e6ab90d53188eecc..3aed081f0da239d8ffcc99dd58ae7f105b8aadb2 100644 (file)
@@ -55,7 +55,15 @@ void submission_subscribe()
   gedcom_subscribe_to_element(ELT_SUBN_RIN, subn_rin_start, def_elt_end);  
 }
 
   gedcom_subscribe_to_element(ELT_SUBN_RIN, subn_rin_start, def_elt_end);  
 }
 
-void submission_cleanup()
+void UNREFALLFUNC(submission)()
+{
+  if (gom_submission) {
+    unref_xref_value(gom_submission->submitter);
+    UNREFALLFUNC(user_data)(gom_submission->extra);
+  }
+}
+
+void CLEANFUNC(submission)()
 {
   if (gom_submission) {
     SAFE_FREE(gom_submission->xrefstr);
 {
   if (gom_submission) {
     SAFE_FREE(gom_submission->xrefstr);
@@ -66,7 +74,6 @@ void submission_cleanup()
     SAFE_FREE(gom_submission->ordinance_process_flag);
     SAFE_FREE(gom_submission->record_id);
     DESTROY_CHAIN_ELTS(user_data, gom_submission->extra);
     SAFE_FREE(gom_submission->ordinance_process_flag);
     SAFE_FREE(gom_submission->record_id);
     DESTROY_CHAIN_ELTS(user_data, gom_submission->extra);
-    SAFE_FREE(gom_submission);
   }
 }
 
   }
 }
 
@@ -95,8 +102,7 @@ void DESTROYFUNC(submission)()
 {
   if (gom_submission) {
     submission_cleanup();
 {
   if (gom_submission) {
     submission_cleanup();
-    free(gom_submission);
-    gom_submission = NULL;
+    SAFE_FREE(gom_submission);
   }
 }
 
   }
 }
 
@@ -127,8 +133,10 @@ int DELETEFUNC(submission)()
   int result = 1;
   if (gom_submission) {
     result = gedcom_delete_xref(gom_submission->xrefstr);
   int result = 1;
   if (gom_submission) {
     result = gedcom_delete_xref(gom_submission->xrefstr);
-    if (result == 0)
+    if (result == 0) {
+      UNREFALLFUNC(submission)();
       DESTROYFUNC(submission)();
       DESTROYFUNC(submission)();
+    }
   }
   return result;
 }
   }
   return result;
 }
index 29de511f9e4dee349789b842df1b8a07d0ebbbf5..06376b26d639aa142804de7ead813ba6e1963032 100644 (file)
@@ -91,6 +91,16 @@ void submitter_subscribe()
   gedcom_subscribe_to_element(ELT_SUBM_RIN, subm_rin_start, def_elt_end);
 }
 
   gedcom_subscribe_to_element(ELT_SUBM_RIN, subm_rin_start, def_elt_end);
 }
 
+void UNREFALLFUNC(submitter)(struct submitter *obj)
+{
+  if (obj) {
+    UNREFALLFUNC(address)(obj->address);
+    UNREFALLFUNC(multimedia_link)(obj->mm_link);
+    UNREFALLFUNC(change_date)(obj->change_date);
+    UNREFALLFUNC(user_data)(obj->extra);
+  }
+}
+
 void CLEANFUNC(submitter)(struct submitter* rec)
 {
   if (rec) {
 void CLEANFUNC(submitter)(struct submitter* rec)
 {
   if (rec) {
index 90ffb0b995549443ce630451fcf7679290dd4f60..a685f3def47c8f4bdaa7d2da41d918429e16dac8 100644 (file)
@@ -247,6 +247,15 @@ void user_rec_subscribe()
   gedcom_subscribe_to_element(ELT_USER, user_elt_start, def_elt_end);
 }
 
   gedcom_subscribe_to_element(ELT_USER, user_elt_start, def_elt_end);
 }
 
+void UNREFALLFUNC(user_data)(struct user_data *obj)
+{
+  if (obj) {
+    struct user_data* runner;
+    for (runner = obj; runner; runner = runner->next)
+      unref_xref_value(runner->xref_value);
+  }
+}
+
 void CLEANFUNC(user_data)(struct user_data* data)
 {
   if (data) {
 void CLEANFUNC(user_data)(struct user_data* data)
 {
   if (data) {
@@ -255,6 +264,14 @@ void CLEANFUNC(user_data)(struct user_data* data)
   }
 }
 
   }
 }
 
+void UNREFALLFUNC(user_rec)(struct user_rec *obj)
+{
+  if (obj) {
+    unref_xref_value(obj->xref_value);
+    UNREFALLFUNC(user_data)(obj->extra);
+  }
+}
+
 void CLEANFUNC(user_rec)(struct user_rec* rec)
 {
   if (rec) {
 void CLEANFUNC(user_rec)(struct user_rec* rec)
 {
   if (rec) {
index 58f055efd76c59c097ec11d5bab1527dc1d0da59..071e2ecfe3295f99a9c1dc6d9574f3c1256733e2 100644 (file)
@@ -35,6 +35,7 @@ int write_user_data(Gedcom_write_hndl hndl, struct user_data* data);
 DECLARE_MAKEFUNC(user_rec);
 DECLARE_ADDFUNC2(user_rec, user_data);
 
 DECLARE_MAKEFUNC(user_rec);
 DECLARE_ADDFUNC2(user_rec, user_data);
 
+DECLARE_UNREFALLFUNC(user_data);
 DECLARE_CLEANFUNC(user_data);
 
 #endif /* __USER_REC_H */
 DECLARE_CLEANFUNC(user_data);
 
 #endif /* __USER_REC_H */
index c9440ab7e8b63efe78d67f20876deabaf1d62e64..2c08e3afa8216a3db20cb753db22987673449a7e 100644 (file)
@@ -123,6 +123,15 @@ void user_ref_subscribe()
                              def_elt_end);
 }
 
                              def_elt_end);
 }
 
+void UNREFALLFUNC(user_ref_number)(struct user_ref_number* obj)
+{
+  if (obj) {
+    struct user_ref_number* runner;
+    for (runner = obj; runner; runner = runner->next)
+      UNREFALLFUNC(user_data)(runner->extra);
+  }
+}
+
 void CLEANFUNC(user_ref_number)(struct user_ref_number* refn)
 {
   if (refn) {
 void CLEANFUNC(user_ref_number)(struct user_ref_number* refn)
 {
   if (refn) {
index 8246d8b3484be97d659390e3190a9adc3ebc5480..c7c287809b97c0efeb4f2f4787065b94e5525c84 100644 (file)
@@ -33,6 +33,7 @@ int write_user_refs(Gedcom_write_hndl hndl, int parent,
 
 DECLARE_SUB_MAKEFUNC(user_ref_number);
 
 
 DECLARE_SUB_MAKEFUNC(user_ref_number);
 
+DECLARE_UNREFALLFUNC(user_ref_number);
 DECLARE_CLEANFUNC(user_ref_number);
 DECLARE_ADDFUNC2(user_ref_number, user_data);
 
 DECLARE_CLEANFUNC(user_ref_number);
 DECLARE_ADDFUNC2(user_ref_number, user_data);