- char *str = GEDCOM_STRING(parsed_value);
- struct association *obj = SAFE_CTXT_CAST(association, (Gom_ctxt)parent);
- if (obj)
- obj->type = strdup(str);
- set_xref_type(obj->to, str);
- return (Gedcom_ctxt) MAKE_GOM_CTXT(elt, association, obj);
+ Gom_ctxt ctxt = (Gom_ctxt)parent;
+ Gom_ctxt result = NULL;
+
+ if (! ctxt)
+ NO_CONTEXT;
+ else {
+ struct association *obj = SAFE_CTXT_CAST(association, ctxt);
+ char *str = GEDCOM_STRING(parsed_value);
+ if (obj) {
+ obj->type = strdup(str);
+ if (! obj->type)
+ MEMORY_ERROR;
+ else {
+ set_xref_type(obj->to, str);
+ result = MAKE_GOM_CTXT(elt, association, obj);
+ }
+ }
+ }
+ return (Gedcom_ctxt)result;