From: Miek Gieben Date: Fri, 25 Feb 2005 10:06:48 +0000 (+0000) Subject: pop function created X-Git-Tag: release-0.50~366 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=db386ba63bf09c3a95c5feafca86a191ac67417a;p=thirdparty%2Fldns.git pop function created --- diff --git a/rr.c b/rr.c index 85b35482..1c292e92 100644 --- a/rr.c +++ b/rr.c @@ -228,6 +228,34 @@ ldns_rr_push_rdf(ldns_rr *rr, ldns_rdf *f) return true; } +/** + * remove a rd_field member, it will be + * popped from the last place + * \param[in] *rr rr to operate on + * \return rdf which was popped (null if nothing) + */ +ldns_rdf * +ldns_rr_pop_rdf(ldns_rr *rr) +{ + uint16_t rd_count; + ldns_rdf *pop; + + rd_count = ldns_rr_rd_count(rr); + + if (rd_count == 0) { + return NULL; + } + + pop = rr->_rdata_fields[rd_count]; + + /* grow the array */ + rr->_rdata_fields = XREALLOC( + rr->_rdata_fields, ldns_rdf *, rd_count - 1); + + ldns_rr_set_rd_count(rr, rd_count - 1); + return pop; +} + /** * set the rdata field member counter * \param[in] *rr rr to operate on @@ -337,6 +365,7 @@ ldns_rr_list_free(ldns_rr_list *rr_list) FREE(rr_list); } +/* need a pop here too */ bool ldns_rr_list_push_rr(ldns_rr_list *rr_list, ldns_rr *rr) {