]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
pop function created
authorMiek Gieben <miekg@NLnetLabs.nl>
Fri, 25 Feb 2005 10:06:48 +0000 (10:06 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Fri, 25 Feb 2005 10:06:48 +0000 (10:06 +0000)
rr.c

diff --git a/rr.c b/rr.c
index 85b354822ebf09434471b0bf52a698e0accd8885..1c292e9264c0a53183f98ab9d5e82c9446624e28 100644 (file)
--- 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)
 {