move isc_region_compare to isc/region.[ch], not isc/buffer.[ch]
This commit is contained 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}
|
||||
|
||||
@@ -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 <config.h>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
43
lib/isc/region.c
Normal file
43
lib/isc/region.c
Normal file
@@ -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 <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/region.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user