From e74100e3f43887f048643973a1f4351daa3a9628 Mon Sep 17 00:00:00 2001 From: Brian Wellington Date: Sat, 5 Jan 2002 07:28:44 +0000 Subject: [PATCH] move isc_region_compare to isc/region.[ch], not isc/buffer.[ch] --- lib/isc/Makefile.in | 4 ++-- lib/isc/buffer.c | 19 +--------------- lib/isc/include/isc/buffer.h | 16 +------------- lib/isc/include/isc/region.h | 17 +++++++++++++- lib/isc/region.c | 43 ++++++++++++++++++++++++++++++++++++ util/copyrights | 1 + 6 files changed, 64 insertions(+), 36 deletions(-) create mode 100644 lib/isc/region.c diff --git a/lib/isc/Makefile.in b/lib/isc/Makefile.in index ccf1317acc..a7a0887ba1 100644 --- a/lib/isc/Makefile.in +++ b/lib/isc/Makefile.in @@ -13,7 +13,7 @@ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# $Id: Makefile.in,v 1.73 2001/11/30 01:02:12 gson Exp $ +# $Id: Makefile.in,v 1.74 2002/01/05 07:28:38 bwelling Exp $ srcdir = @srcdir@ VPATH = @srcdir@ @@ -56,7 +56,7 @@ OBJS = @ISC_EXTRA_OBJS@ \ lex.@O@ lfsr.@O@ lib.@O@ log.@O@ \ md5.@O@ mem.@O@ mutexblock.@O@ netaddr.@O@ ondestroy.@O@ \ parseint.@O@ quota.@O@ random.@O@ \ - ratelimiter.@O@ result.@O@ rwlock.@O@ \ + ratelimiter.@O@ region.@O@ result.@O@ rwlock.@O@ \ serial.@O@ sha1.@O@ sockaddr.@O@ string.@O@ symtab.@O@ \ task.@O@ taskpool.@O@ timer.@O@ version.@O@ \ ${UNIXOBJS} ${NLSOBJS} ${THREADOBJS} diff --git a/lib/isc/buffer.c b/lib/isc/buffer.c index 05aba4ce43..eb14715c6c 100644 --- a/lib/isc/buffer.c +++ b/lib/isc/buffer.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: buffer.c,v 1.37 2002/01/05 07:05:02 ogud Exp $ */ +/* $Id: buffer.c,v 1.38 2002/01/05 07:28:39 bwelling Exp $ */ #include @@ -367,23 +367,6 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r) { return (ISC_R_SUCCESS); } -int -isc_region_compare(isc_region_t *r1, isc_region_t *r2) { - unsigned int l; - int result; - - REQUIRE(r1 != NULL); - REQUIRE(r2 != NULL); - - l = (r1->length < r2->length) ? r1->length : r2->length; - - if ((result = memcmp(r1->base, r2->base, l)) != 0) - return ((result < 0) ? -1 : 1); - else - return ((r1->length == r2->length) ? 0 : - (r1->length < r2->length) ? -1 : 1); -} - isc_result_t isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer, unsigned int length) diff --git a/lib/isc/include/isc/buffer.h b/lib/isc/include/isc/buffer.h index 45f2cde1fa..736050aac3 100644 --- a/lib/isc/include/isc/buffer.h +++ b/lib/isc/include/isc/buffer.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: buffer.h,v 1.40 2002/01/05 07:05:04 ogud Exp $ */ +/* $Id: buffer.h,v 1.41 2002/01/05 07:28:41 bwelling Exp $ */ #ifndef ISC_BUFFER_H #define ISC_BUFFER_H 1 @@ -570,20 +570,6 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r); * ISC_R_NOSPACE The available region of 'b' is not * big enough. */ -int -isc_region_compare(isc_region_t *r1, isc_region_t *r2); -/* - * Compares the contents of two regions - * - * Requires: - * 'r1' is a valid region - * 'r2' is a valid region - * - * Returns: - * < 0 if r1 is lexicographicly less than r2 - * = 0 if r1 is lexicographicly identical to r2 - * > 0 if r1 is lexicographicly greater than r2 - */ ISC_LANG_ENDDECLS diff --git a/lib/isc/include/isc/region.h b/lib/isc/include/isc/region.h index 6cfccf812f..41c6a5702e 100644 --- a/lib/isc/include/isc/region.h +++ b/lib/isc/include/isc/region.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: region.h,v 1.16 2001/01/09 21:57:25 bwelling Exp $ */ +/* $Id: region.h,v 1.17 2002/01/05 07:28:42 bwelling Exp $ */ #ifndef ISC_REGION_H #define ISC_REGION_H 1 @@ -77,4 +77,19 @@ struct isc_consttextregion { _r->length -= _l; \ } while (0) +int +isc_region_compare(isc_region_t *r1, isc_region_t *r2); +/* + * Compares the contents of two regions + * + * Requires: + * 'r1' is a valid region + * 'r2' is a valid region + * + * Returns: + * < 0 if r1 is lexicographically less than r2 + * = 0 if r1 is lexicographically identical to r2 + * > 0 if r1 is lexicographically greater than r2 + */ + #endif /* ISC_REGION_H */ diff --git a/lib/isc/region.c b/lib/isc/region.c new file mode 100644 index 0000000000..0625a9320a --- /dev/null +++ b/lib/isc/region.c @@ -0,0 +1,43 @@ +/* + * Copyright (C) 1998-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM + * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: region.c,v 1.1 2002/01/05 07:28:40 bwelling Exp $ */ + +#include + +#include +#include + +#include +#include + +int +isc_region_compare(isc_region_t *r1, isc_region_t *r2) { + unsigned int l; + int result; + + REQUIRE(r1 != NULL); + REQUIRE(r2 != NULL); + + l = (r1->length < r2->length) ? r1->length : r2->length; + + if ((result = memcmp(r1->base, r2->base, l)) != 0) + return ((result < 0) ? -1 : 1); + else + return ((r1->length == r2->length) ? 0 : + (r1->length < r2->length) ? -1 : 1); +} diff --git a/util/copyrights b/util/copyrights index eee11c65e0..e0f756c629 100644 --- a/util/copyrights +++ b/util/copyrights @@ -1918,6 +1918,7 @@ ./lib/isc/quota.c C 2000,2001 ./lib/isc/random.c C 1999,2000,2001 ./lib/isc/ratelimiter.c C 1999,2000,2001 +./lib/isc/region.c C 2002 ./lib/isc/result.c C 1998,1999,2000,2001 ./lib/isc/rwlock.c C 1998,1999,2000,2001 ./lib/isc/serial.c C 1999,2000,2001