- struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
- repo->address = address;
-}
-
-void repository_add_phone(Gom_ctxt ctxt, char *phone)
-{
- struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
- if (! repo->phone[0])
- repo->phone[0] = strdup(phone);
- else if (! repo->phone[1])
- repo->phone[1] = strdup(phone);
- else if (! repo->phone[2])
- repo->phone[2] = strdup(phone);
-}
-
-void repository_add_note(Gom_ctxt ctxt, struct note_sub* note)
-{
- struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
- LINK_CHAIN_ELT(note_sub, repo->note, note)
-}
-
-void repository_add_user_ref(Gom_ctxt ctxt, struct user_ref_number* ref)
-{
- struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
- LINK_CHAIN_ELT(user_ref_number, repo->ref, ref)
-}
-
-void repository_set_record_id(Gom_ctxt ctxt, char *rin)
-{
- struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
- repo->record_id = strdup(rin);
-}
-
-void repository_set_change_date(Gom_ctxt ctxt, struct change_date* chan)
-{
- struct repository *repo = SAFE_CTXT_CAST(repository, ctxt);
- repo->change_date = chan;
-}
-
-void repository_add_user_data(Gom_ctxt ctxt, struct user_data* data)
-{
- struct repository *obj = SAFE_CTXT_CAST(repository, ctxt);
- LINK_CHAIN_ELT(user_data, obj->extra, data)
-}
-
-void repository_cleanup(struct repository* repo)
-{
- SAFE_FREE(repo->xrefstr);
- SAFE_FREE(repo->name);
- address_cleanup(repo->address);
- SAFE_FREE(repo->phone[0]);
- SAFE_FREE(repo->phone[1]);
- SAFE_FREE(repo->phone[2]);
- DESTROY_CHAIN_ELTS(note_sub, repo->note, note_sub_cleanup)
- DESTROY_CHAIN_ELTS(user_ref_number, repo->ref, user_ref_cleanup)
- SAFE_FREE(repo->record_id);
- change_date_cleanup(repo->change_date);
- DESTROY_CHAIN_ELTS(user_data, repo->extra, user_data_cleanup)
+ if (repo) {
+ SAFE_FREE(repo->xrefstr);
+ SAFE_FREE(repo->name);
+ CLEANFUNC(address)(repo->address);
+ SAFE_FREE(repo->phone[0]);
+ SAFE_FREE(repo->phone[1]);
+ SAFE_FREE(repo->phone[2]);
+ DESTROY_CHAIN_ELTS(note_sub, repo->note);
+ DESTROY_CHAIN_ELTS(user_ref_number, repo->ref);
+ SAFE_FREE(repo->record_id);
+ CLEANFUNC(change_date)(repo->change_date);
+ DESTROY_CHAIN_ELTS(user_data, repo->extra);
+ }