X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gom%2Fsource_description.c;h=02d093fbeb0cd6707e71e055fa06e55c921fa4e2;hb=866835ac8928d7e40919c2ca59799cb37023856f;hp=34ca5216f79f08f838cc3a106d7b0760cce4b519;hpb=72689522e287ca3b2231e7d8881f0fe5bea48f15;p=gedcom-parse.git diff --git a/gom/source_description.c b/gom/source_description.c index 34ca521..02d093f 100644 --- a/gom/source_description.c +++ b/gom/source_description.c @@ -38,12 +38,8 @@ Gedcom_ctxt sub_sour_caln_start(_ELT_PARAMS_) if (! ctxt) NO_CONTEXT; else { - struct source_description *desc - = (struct source_description *)malloc(sizeof(struct source_description)); - if (! desc) - MEMORY_ERROR; - else { - memset (desc, 0, sizeof(struct source_description)); + struct source_description *desc = SUB_MAKEFUNC(source_description)(); + if (desc) { desc->call_number = strdup(GEDCOM_STRING(parsed_value)); if (! desc->call_number) { @@ -51,11 +47,12 @@ Gedcom_ctxt sub_sour_caln_start(_ELT_PARAMS_) free(desc); } else { - switch (ctxt->ctxt_type) { + int type = ctxt_type(ctxt); + switch (type) { case ELT_SUB_REPO: ADDFUNC2(source,source_description)(ctxt, desc); break; default: - UNEXPECTED_CONTEXT(ctxt->ctxt_type); + UNEXPECTED_CONTEXT(type); } result = MAKE_GOM_CTXT(elt, source_description, desc); } @@ -65,6 +62,12 @@ Gedcom_ctxt sub_sour_caln_start(_ELT_PARAMS_) return (Gedcom_ctxt)result; } +DEFINE_SUB_MAKEFUNC(source_description) +DEFINE_SUB_ADDFUNC(source_description) +DEFINE_SUB_FINDFUNC(source_description) +DEFINE_SUB_REMOVEFUNC(source_description) +DEFINE_SUB_MOVEFUNC(source_description) + DEFINE_STRING_CB(source_description, sub_sour_caln_medi_start, media) DEFINE_ADDFUNC2(source_description, user_data, extra) @@ -77,6 +80,16 @@ void source_description_subscribe() 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) {