- struct note_sub *note = NULL;
-
- if (ctxt) {
- note = (struct note_sub *)malloc(sizeof(struct note_sub));
- memset (note, 0, sizeof(struct note_sub));
- if (GEDCOM_IS_STRING(parsed_value))
- note->text = strdup(GEDCOM_STRING(parsed_value));
- else if (GEDCOM_IS_XREF_PTR(parsed_value))
- note->reference = GEDCOM_XREF_PTR(parsed_value);
-
- switch (ctxt->ctxt_type) {
- case ELT_SUB_PLAC:
- place_add_note(ctxt, note); break;
- case ELT_SUB_FAM_EVT:
- case ELT_SUB_FAM_EVT_EVEN:
- case ELT_SUB_INDIV_ATTR:
- case ELT_SUB_INDIV_RESI:
- case ELT_SUB_INDIV_BIRT:
- case ELT_SUB_INDIV_GEN:
- case ELT_SUB_INDIV_ADOP:
- case ELT_SUB_INDIV_EVEN:
- event_add_note(ctxt, note); break;
- case ELT_SUB_SOUR:
- citation_add_note(ctxt, note); break;
- case ELT_SUB_MULTIM_OBJE:
- multimedia_link_add_note(ctxt, note); break;
- case ELT_SUB_LSS_SLGS:
- case ELT_SUB_LIO_BAPL:
- case ELT_SUB_LIO_SLGC:
- lds_event_add_note(ctxt, note); break;
- case REC_FAM:
- family_add_note(ctxt, note); break;
- case ELT_SUB_CHAN:
- change_date_add_note(ctxt, note); break;
- case ELT_SUB_PERS_NAME:
- name_add_note(ctxt, note); break;
- case ELT_SUB_FAMC:
- case ELT_SUB_FAMS:
- family_link_add_note(ctxt, note); break;
- case ELT_SUB_ASSO:
- association_add_note(ctxt, note); break;
- case REC_INDI:
- individual_add_note(ctxt, note); break;
- case REC_OBJE:
- multimedia_add_note(ctxt, note); break;
- case REC_REPO:
- repository_add_note(ctxt, note); break;
- case ELT_SOUR_DATA:
- source_add_note_to_data(ctxt, note); break;
- case ELT_SUB_REPO:
- source_add_note_to_repo(ctxt, note); break;
- case REC_SOUR:
- source_add_note(ctxt, note); break;
- default:
- UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+ Gom_ctxt result = NULL;
+
+ if (! ctxt)
+ NO_CONTEXT;
+ else {
+ struct note_sub *note = (struct note_sub *)malloc(sizeof(struct note_sub));
+ if (! note)
+ MEMORY_ERROR;
+ else {
+ memset (note, 0, sizeof(struct note_sub));
+ if (GEDCOM_IS_XREF_PTR(parsed_value))
+ note->reference = GEDCOM_XREF_PTR(parsed_value);
+
+ switch (ctxt->ctxt_type) {
+ case ELT_SUB_PLAC:
+ place_add_note(ctxt, note); break;
+ case ELT_SUB_FAM_EVT:
+ case ELT_SUB_FAM_EVT_EVEN:
+ case ELT_SUB_INDIV_ATTR:
+ case ELT_SUB_INDIV_RESI:
+ case ELT_SUB_INDIV_BIRT:
+ case ELT_SUB_INDIV_GEN:
+ case ELT_SUB_INDIV_ADOP:
+ case ELT_SUB_INDIV_EVEN:
+ event_add_note(ctxt, note); break;
+ case ELT_SUB_SOUR:
+ citation_add_note(ctxt, note); break;
+ case ELT_SUB_MULTIM_OBJE:
+ multimedia_link_add_note(ctxt, note); break;
+ case ELT_SUB_LSS_SLGS:
+ case ELT_SUB_LIO_BAPL:
+ case ELT_SUB_LIO_SLGC:
+ lds_event_add_note(ctxt, note); break;
+ case REC_FAM:
+ family_add_note(ctxt, note); break;
+ case ELT_SUB_CHAN:
+ change_date_add_note(ctxt, note); break;
+ case ELT_SUB_PERS_NAME:
+ name_add_note(ctxt, note); break;
+ case ELT_SUB_FAMC:
+ case ELT_SUB_FAMS:
+ family_link_add_note(ctxt, note); break;
+ case ELT_SUB_ASSO:
+ association_add_note(ctxt, note); break;
+ case REC_INDI:
+ individual_add_note(ctxt, note); break;
+ case REC_OBJE:
+ multimedia_add_note(ctxt, note); break;
+ case REC_REPO:
+ repository_add_note(ctxt, note); break;
+ case ELT_SOUR_DATA:
+ source_add_note_to_data(ctxt, note); break;
+ case ELT_SUB_REPO:
+ source_add_note_to_repo(ctxt, note); break;
+ case REC_SOUR:
+ source_add_note(ctxt, note); break;
+ default:
+ UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+ }
+ result = MAKE_GOM_CTXT(elt, note_sub, note);