rdataslab.c revision 122d284b6112bae486400466769fe474771947c7
f428e385a4f7a42196b53de8e134909e8c488258Automatic Updater * Copyright (C) 1999, 2000 Internet Software Consortium.
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * copyright notice and this permission notice appear in all copies.
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
f428e385a4f7a42196b53de8e134909e8c488258Automatic Updater/* $Id: rdataslab.c,v 1.18 2000/09/01 16:39:07 gson Exp $ */
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#include <isc/string.h> /* Required for HP/UX (and others?) */
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews/* Note: the "const void *" are just to make qsort happy. */
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews int len = ISC_MIN(rdata1->length, rdata2->length);
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrewsdns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
f428e385a4f7a42196b53de8e134909e8c488258Automatic Updater isc_region_t *region, unsigned int reservelen)
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews unsigned char *rawbuf;
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews unsigned int buflen;
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews unsigned int nitems;
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews unsigned int nalloc;
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews unsigned int i;
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews rdatas = isc_mem_get(mctx, nalloc * sizeof(dns_rdata_t));
10f9e687f5824b41083c497adb4d0c54f965ebd6Mark Andrews * Save all of the rdata members into an array.
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews for (i = 0; i < nalloc; i++) {
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews qsort(rdatas, nalloc, sizeof(dns_rdata_t), compare_rdata);
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * Remove duplicates.
10f9e687f5824b41083c497adb4d0c54f965ebd6Mark Andrews if (compare_rdata(&rdatas[i-1], &rdatas[i]) == 0) {
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * Run through the rdataset list once, counting up the size
for (i = 0; i < nalloc; i++) {
return (result);
return (ISC_R_NOMEMORY);
for (i = 0; i < nalloc; i++) {
return (ISC_R_SUCCESS);
unsigned char *current;
while (count > 0) {
count--;
static inline isc_boolean_t
unsigned int count, i;
unsigned char *current;
for (i = 0; i < count; i++) {
return (ISC_TRUE);
return (ISC_FALSE);
unsigned int oadded = 0;
unsigned int nadded = 0;
unsigned int nncount = 0;
olength = 0;
tcount++;
nncount++;
ncount--;
} while (ncount > 0);
return (DNS_R_UNCHANGED);
return (ISC_R_NOMEMORY);
if (ocount > 0)
if (ncount > 0) {
if (fromold) {
oadded++;
&ordata);
nadded++;
&nrdata));
return (ISC_R_SUCCESS);
unsigned char **tslabp)
tcount = 0;
tcount++;
mcount--;
} while (mcount > 0);
if (tcount == 0)
return (DNS_R_NXRRSET);
if (!removed_something)
return (DNS_R_UNCHANGED);
return (ISC_R_NOMEMORY);
mcount--;
} while (mcount > 0);
return (ISC_R_SUCCESS);
unsigned int reservelen)
return (ISC_FALSE);
while (count1 > 0) {
return (ISC_FALSE);
count1--;
return (ISC_TRUE);