X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gom%2Fplace.c;h=779ea87881591a1c558d9fd06df7efe53aeb7840;hb=866835ac8928d7e40919c2ca59799cb37023856f;hp=8ceb152b94c6fcfc89aed9cee9a7710feba8f1d5;hpb=72689522e287ca3b2231e7d8881f0fe5bea48f15;p=gedcom-parse.git diff --git a/gom/place.c b/gom/place.c index 8ceb152..779ea87 100644 --- a/gom/place.c +++ b/gom/place.c @@ -41,11 +41,8 @@ Gedcom_ctxt sub_place_start(_ELT_PARAMS_) if (! ctxt) NO_CONTEXT; else { - struct place *place = (struct place *)malloc(sizeof(struct place)); - if (! place) - MEMORY_ERROR; - else { - memset (place, 0, sizeof(struct place)); + struct place *place = SUB_MAKEFUNC(place)(); + if (place) { place->value = strdup(GEDCOM_STRING(parsed_value)); if (!place->value) { @@ -53,7 +50,8 @@ Gedcom_ctxt sub_place_start(_ELT_PARAMS_) free(place); } else { - switch (ctxt->ctxt_type) { + int type = ctxt_type(ctxt); + switch (type) { case ELT_SUB_FAM_EVT: case ELT_SUB_FAM_EVT_EVEN: case ELT_SUB_INDIV_ATTR: @@ -64,7 +62,7 @@ Gedcom_ctxt sub_place_start(_ELT_PARAMS_) case ELT_SUB_INDIV_EVEN: ADDFUNC2_NOLIST(event,place)(ctxt, place); break; default: - UNEXPECTED_CONTEXT(ctxt->ctxt_type); + UNEXPECTED_CONTEXT(type); } result = MAKE_GOM_CTXT(elt, place, place); } @@ -74,6 +72,10 @@ Gedcom_ctxt sub_place_start(_ELT_PARAMS_) return (Gedcom_ctxt)result; } +DEFINE_SUB_MAKEFUNC(place) +DEFINE_SUB_SETFUNC(place) +DEFINE_SUB_DELETEFUNC(place) + DEFINE_STRING_CB(place, sub_place_form_start, place_hierarchy) DEFINE_ADDFUNC2(place, source_citation, citation) @@ -87,6 +89,15 @@ void place_subscribe() 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) {