Unlink xrefs properly when struct is deleted.
[gedcom-parse.git] / gom / source_citation.c
index c79efcce1ce97c94cb92647fcb11047ae3ce87aa..64ad42b4e7bb34ee1331bdc8424185155c4fe2cb 100644 (file)
@@ -166,6 +166,15 @@ void citation_subscribe()
                              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) {
@@ -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) {