Logo Search packages:      
Sourcecode: ldns version File versions  Download package

ldns_rr* ldns_rr_list_pop_rr ( ldns_rr_list rr_list  ) 

pops the last rr from an rrlist.

Parameters:
[in] rr_list the rr_list to pop from
Returns:
NULL if nothing to pop. Otherwise the popped RR

Definition at line 911 of file rr.c.

References ldns_struct_rr_list::_rr_capacity, ldns_struct_rr_list::_rrs, ldns_rr_list_pop_rr(), ldns_rr_list_rr(), ldns_rr_list_rr_count(), and ldns_rr_list_set_rr_count().

Referenced by ldns_rr_list_pop_rr(), ldns_rr_list_pop_rr_list(), ldns_rr_list_pop_rrset(), and ldns_rr_set_pop_rr().

{
      size_t rr_count;
      size_t cap;
      ldns_rr *pop;
      
      rr_count = ldns_rr_list_rr_count(rr_list);

      if (rr_count == 0) {
            return NULL;
      }

      cap = rr_list->_rr_capacity;
      pop = ldns_rr_list_rr(rr_list, rr_count - 1);
      
      /* shrink the array */
      if(cap > LDNS_RRLIST_INIT && rr_count-1 <= cap/2) {
            cap /= 2;
            rr_list->_rrs = LDNS_XREALLOC(rr_list->_rrs, ldns_rr *, cap);
            rr_list->_rr_capacity = cap;
      }

      ldns_rr_list_set_rr_count(rr_list, rr_count - 1);

      return pop;
}


Generated by  Doxygen 1.6.0   Back to index