From: Peter Verthez Date: Sun, 5 Jan 2003 17:43:16 +0000 (+0000) Subject: Definition of SUB_MAKEFUNC, SUB_ADDFUNC and SUB_DELETEFUNC. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=7ae7ece158a1d930a77806f591b1d16b2cde581f;p=gedcom-parse.git Definition of SUB_MAKEFUNC, SUB_ADDFUNC and SUB_DELETEFUNC. --- diff --git a/gom/address.c b/gom/address.c index 916737a..fa8a3ee 100644 --- a/gom/address.c +++ b/gom/address.c @@ -41,11 +41,8 @@ Gedcom_ctxt sub_addr_start(_ELT_PARAMS_) if (!ctxt) NO_CONTEXT; else { - struct address *addr = (struct address *)malloc(sizeof(struct address)); - if (!addr) - MEMORY_ERROR; - else { - memset (addr, 0, sizeof(struct address)); + struct address *addr = SUB_MAKEFUNC(address)(); + if (addr) { switch (ctxt->ctxt_type) { case ELT_HEAD_SOUR_CORP: ADDFUNC2_NOLIST(header,address)(ctxt, addr); break; @@ -84,6 +81,10 @@ Gedcom_ctxt sub_addr_cont_start(_ELT_PARAMS_) return (Gedcom_ctxt)result; } +DEFINE_SUB_MAKEFUNC(address) +DEFINE_SUB_ADDFUNC(address) +DEFINE_SUB_DELETEFUNC(address) + DEFINE_STRING_END_CB(address, sub_addr_end, full_label) DEFINE_STRING_CB(address, sub_addr_adr1_start, line1) DEFINE_STRING_CB(address, sub_addr_adr2_start, line2) diff --git a/gom/change_date.c b/gom/change_date.c index 1038df3..bf51134 100644 --- a/gom/change_date.c +++ b/gom/change_date.c @@ -46,13 +46,8 @@ Gedcom_ctxt sub_chan_start(_ELT_PARAMS_) if (! ctxt) NO_CONTEXT; else { - struct change_date *chan - = (struct change_date *)malloc(sizeof(struct change_date)); - if (! chan) - MEMORY_ERROR; - else { - memset (chan, 0, sizeof(struct change_date)); - + struct change_date *chan = SUB_MAKEFUNC(change_date)(); + if (chan) { switch (ctxt->ctxt_type) { case REC_FAM: ADDFUNC2_NOLIST(family,change_date)(ctxt, chan); break; @@ -78,6 +73,10 @@ Gedcom_ctxt sub_chan_start(_ELT_PARAMS_) return (Gedcom_ctxt)result; } +DEFINE_SUB_MAKEFUNC(change_date) +DEFINE_SUB_ADDFUNC(change_date) +DEFINE_SUB_DELETEFUNC(change_date) + DEFINE_DATE_CB(change_date, sub_chan_date_start, date) DEFINE_STRING_CB(change_date, sub_chan_time_start, time) @@ -104,33 +103,6 @@ void CLEANFUNC(change_date)(struct change_date *chan) SAFE_FREE(chan); } -struct change_date* gom_add_change_date(struct change_date** chan) -{ - struct change_date *obj = NULL; - if (chan && ! *chan) { - obj = (struct change_date*) malloc(sizeof(struct change_date)); - if (! obj) - MEMORY_ERROR; - else { - memset(obj, 0, sizeof(struct change_date)); - *chan = obj; - } - } - return obj; -} - -int gom_delete_change_date(struct change_date** chan) -{ - int result = 1; - if (chan && *chan) { - CLEANFUNC(change_date)(*chan); - free(*chan); - *chan = NULL; - result = 0; - } - return result; -} - int update_date(struct date_value** dv, struct tm* tm_ptr) { int result; diff --git a/gom/place.c b/gom/place.c index 8ceb152..cb85253 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) { @@ -74,6 +71,10 @@ Gedcom_ctxt sub_place_start(_ELT_PARAMS_) return (Gedcom_ctxt)result; } +DEFINE_SUB_MAKEFUNC(place) +DEFINE_SUB_ADDFUNC(place) +DEFINE_SUB_DELETEFUNC(place) + DEFINE_STRING_CB(place, sub_place_form_start, place_hierarchy) DEFINE_ADDFUNC2(place, source_citation, citation)