X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gom%2Ffamily_link.c;h=cb5435be90781d1f18c3726236479e3da24319de;hb=327069289a45ed1e91d8bfc07d7d89cfbad057d6;hp=39a2140c865b452b3f213231b947ad28a3f6c3fb;hpb=72689522e287ca3b2231e7d8881f0fe5bea48f15;p=gedcom-parse.git diff --git a/gom/family_link.c b/gom/family_link.c index 39a2140..cb5435b 100644 --- a/gom/family_link.c +++ b/gom/family_link.c @@ -39,12 +39,8 @@ Gedcom_ctxt sub_fam_link_start(_ELT_PARAMS_) if (! ctxt) NO_CONTEXT; else { - struct family_link *link - = (struct family_link *)malloc(sizeof(struct family_link)); - if (! link) - MEMORY_ERROR; - else { - memset (link, 0, sizeof(struct family_link)); + struct family_link *link = SUB_MAKEFUNC(family_link)(); + if (link) { link->family = GEDCOM_XREF_PTR(parsed_value); switch (ctxt->ctxt_type) { @@ -87,6 +83,8 @@ Gedcom_ctxt sub_fam_link_pedi_start(_ELT_PARAMS_) return (Gedcom_ctxt)result; } +DEFINE_SUB_MAKEFUNC(family_link) + DEFINE_ADDFUNC2(family_link, note_sub, note) DEFINE_ADDFUNC2(family_link, user_data, extra) @@ -100,6 +98,16 @@ void family_link_subscribe() 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) { @@ -107,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) {