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

void ldns_rr_list_sort ( ldns_rr_list unsorted  ) 

sorts an rr_list (canonical wire format). the sorting is done inband.

Parameters:
[in] unsorted the rr_list to be sorted
Returns:
void

Definition at line 1256 of file rr.c.

References ldns_struct_rr_list::_rrs, ldns_rr_list_rr(), ldns_rr_list_rr_count(), and ldns_rr_list_sort().

Referenced by ldns_rr_list_sort(), and ldns_zone_sort().

{
      struct ldns_schwartzian_compare_struct **sortables;
      size_t item_count;
      size_t i;
      
      if (unsorted) {
            item_count = ldns_rr_list_rr_count(unsorted);
            
            sortables = LDNS_XMALLOC(struct ldns_schwartzian_compare_struct *,
                               item_count);
            for (i = 0; i < item_count; i++) {
                  sortables[i] = LDNS_XMALLOC(struct ldns_schwartzian_compare_struct, 1);
                  sortables[i]->original_object = ldns_rr_list_rr(unsorted, i);
                  sortables[i]->transformed_object = NULL;
            }
            qsort(sortables,
                  item_count,
                  sizeof(struct ldns_schwartzian_compare_struct *),
                  qsort_schwartz_rr_compare);
            for (i = 0; i < item_count; i++) {
                  unsorted->_rrs[i] = sortables[i]->original_object;
                  if (sortables[i]->transformed_object) {
                        ldns_buffer_free(sortables[i]->transformed_object);
                  }
                  LDNS_FREE(sortables[i]);
            }
            LDNS_FREE(sortables);
      }
}


Generated by  Doxygen 1.6.0   Back to index