From: Miek Gieben Date: Wed, 16 Mar 2005 18:36:44 +0000 (+0000) Subject: add a pop X-Git-Tag: release-0.50~232 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b4401062946cda3bcb050ab65b42be8d63da701;p=thirdparty%2Fldns.git add a pop --- diff --git a/keys.c b/keys.c index 372928bf..31037142 100644 --- a/keys.c +++ b/keys.c @@ -84,3 +84,32 @@ ldns_key_list_push_key(ldns_key_list *key_list, ldns_key *key) ldns_key_list_set_key_count(key_list, key_count + 1); return true; } + +/** + * pop the last rr from a rrlist + * \param[in] rr_list the rr_list to pop from + * \return NULL if nothing to pop. Otherwise the popped RR + */ +ldns_key * +ldns_key_list_pop_key(ldns_key_list *key_list) +{ + size_t key_count; + ldns_key *pop; + + key_count = ldns_key_list_key_count(key_list); + + if (key_count == 0) { + return NULL; + } + + pop = ldns_key_list_key(key_list, key_count); + + /* shrink the array */ + key_list->_keys = XREALLOC( + key_list->_keys, ldns_key *, key_count - 1); + + ldns_key_list_set_key_count(key_list, key_count - 1); + + return pop; +} +