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) {
DECLARE_SUB_MAKEFUNC(address);
+DECLARE_UNREFALLFUNC(address);
DECLARE_CLEANFUNC(address);
DECLARE_ADDFUNC2(address, user_data);
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) {
DECLARE_SUB_MAKEFUNC(association);
+DECLARE_UNREFALLFUNC(association);
DECLARE_CLEANFUNC(association);
DECLARE_ADDFUNC2(association, note_sub);
DECLARE_ADDFUNC2(association, source_citation);
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) {
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);
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) {
DECLARE_SUB_MAKEFUNC(event);
+DECLARE_UNREFALLFUNC(event);
DECLARE_CLEANFUNC(event);
DECLARE_ADDFUNC2(event, source_citation);
DECLARE_ADDFUNC2(event, multimedia_link);
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) {
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 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) {
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);
#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 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 DEFINE_DESTROYFUNC(STRUCTTYPE,FIRSTVAL) \
- void CLEANFUNC(STRUCTTYPE)(struct STRUCTTYPE* obj); \
+ DECLARE_CLEANFUNC(STRUCTTYPE); \
void DESTROYFUNC(STRUCTTYPE)(struct STRUCTTYPE* obj) { \
if (obj) { \
CLEANFUNC(STRUCTTYPE)(obj); \
return obj; \
}
-/* TODO: Check whether there are still xrefs linked in */
#define DEFINE_DELETEFUNC(STRUCTTYPE) \
+ DECLARE_UNREFALLFUNC(STRUCTTYPE); \
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); \
+ } \
} \
return result; \
}
{ \
int result = 1; \
if (obj && *obj) { \
+ UNREFALLFUNC(STRUCTTYPE)(*obj); \
CLEANFUNC(STRUCTTYPE)(*obj); \
SAFE_FREE(*obj); \
result = 0; \
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,
#include "func_template.h"
+DECLARE_UNREFALLFUNC(xref_list);
DECLARE_CLEANFUNC(xref_list);
#endif /* __GOM_INTERNAL_H */
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 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) {
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) {
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);
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) {
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) {
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);
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) {
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) {
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);
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) {
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);
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) {
DECLARE_SUB_MAKEFUNC(place);
+DECLARE_UNREFALLFUNC(place);
DECLARE_CLEANFUNC(place);
DECLARE_ADDFUNC2(place, source_citation);
DECLARE_ADDFUNC2(place, note_sub);
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) {
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) {
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 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) {
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);
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) {
DECLARE_SUB_MAKEFUNC(source_description);
+DECLARE_UNREFALLFUNC(source_description);
DECLARE_CLEANFUNC(source_description);
DECLARE_ADDFUNC2(source_description, user_data);
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) {
DECLARE_SUB_MAKEFUNC(source_event);
+DECLARE_UNREFALLFUNC(source_event);
DECLARE_CLEANFUNC(source_event);
DECLARE_ADDFUNC2(source_event, user_data);
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);
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);
}
}
{
if (gom_submission) {
submission_cleanup();
- free(gom_submission);
- gom_submission = NULL;
+ SAFE_FREE(gom_submission);
}
}
int result = 1;
if (gom_submission) {
result = gedcom_delete_xref(gom_submission->xrefstr);
- if (result == 0)
+ if (result == 0) {
+ UNREFALLFUNC(submission)();
DESTROYFUNC(submission)();
+ }
}
return result;
}
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) {
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 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) {
DECLARE_MAKEFUNC(user_rec);
DECLARE_ADDFUNC2(user_rec, user_data);
+DECLARE_UNREFALLFUNC(user_data);
DECLARE_CLEANFUNC(user_data);
#endif /* __USER_REC_H */
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) {
DECLARE_SUB_MAKEFUNC(user_ref_number);
+DECLARE_UNREFALLFUNC(user_ref_number);
DECLARE_CLEANFUNC(user_ref_number);
DECLARE_ADDFUNC2(user_ref_number, user_data);