From d3f480009bd89196646b4a19c419e3c1b97c836a Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Mon, 16 Feb 2015 16:01:15 +0100 Subject: [PATCH] Convenience list append functions --- src/list.c | 25 +++++++++++++++++++++++++ src/util-internal.h | 8 ++++++++ 2 files changed, 33 insertions(+) diff --git a/src/list.c b/src/list.c index 207f41b6..3549c1ff 100644 --- a/src/list.c +++ b/src/list.c @@ -480,5 +480,30 @@ getdns_list_set_int(struct getdns_list * list, size_t index, list->items[index].data.n = child_int; return GETDNS_RETURN_GOOD; } /* getdns_list_set_int */ + +getdns_return_t +getdns_list_append_dict(getdns_list *list, const getdns_dict *child_dict) +{ + if (!list) return GETDNS_RETURN_INVALID_PARAMETER; + return getdns_list_set_dict(list, list->numinuse, child_dict); +} +getdns_return_t +getdns_list_append_list(getdns_list *list, const getdns_list *child_list) +{ + if (!list) return GETDNS_RETURN_INVALID_PARAMETER; + return getdns_list_set_list(list, list->numinuse, child_list); +} +getdns_return_t +getdns_list_append_bindata(getdns_list *list, const getdns_bindata *child_bindata) +{ + if (!list) return GETDNS_RETURN_INVALID_PARAMETER; + return getdns_list_set_bindata(list, list->numinuse, child_bindata); +} +getdns_return_t +getdns_list_append_int(getdns_list *list, uint32_t child_int) +{ + if (!list) return GETDNS_RETURN_INVALID_PARAMETER; + return getdns_list_set_int(list, list->numinuse, child_int); +} /* getdns_list.c */ diff --git a/src/util-internal.h b/src/util-internal.h index 7d19c1f5..b75780a1 100644 --- a/src/util-internal.h +++ b/src/util-internal.h @@ -71,6 +71,14 @@ getdns_return_t getdns_apply_network_result(getdns_network_req* netreq, struct u * @return GETDNS_RETURN_GENERAL_ERROR if out of memory */ getdns_return_t getdns_list_add_item(struct getdns_list *list, size_t * index); +getdns_return_t getdns_list_append_dict(getdns_list *list, + const getdns_dict *child_dict); +getdns_return_t getdns_list_append_list(getdns_list *list, + const getdns_list *child_list); +getdns_return_t getdns_list_append_bindata(getdns_list *list, + const getdns_bindata *child_bindata); +getdns_return_t getdns_list_append_int(getdns_list *list, + uint32_t child_uint32); /** * private function (API users should not be calling this), this uses library