]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
add a pop
authorMiek Gieben <miekg@NLnetLabs.nl>
Wed, 16 Mar 2005 18:36:44 +0000 (18:36 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Wed, 16 Mar 2005 18:36:44 +0000 (18:36 +0000)
keys.c

diff --git a/keys.c b/keys.c
index 372928bfe8c0e013e77109c117ec4361a62f4d41..31037142b70e7722d1178fd287f4627a211a4df4 100644 (file)
--- 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;
+}       
+