2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-07 18:15:34 +00:00
Files
bind/lib/isc/bufferlist.c

63 lines
1.7 KiB
C
Raw Normal View History

1999-09-06 04:41:38 +00:00
/*
2000-02-03 23:08:31 +00:00
* Copyright (C) 1999, 2000 Internet Software Consortium.
1999-09-06 04:41:38 +00:00
*
* 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.
1999-09-06 04:41:38 +00:00
*/
/* $Id: bufferlist.c,v 1.10 2000/07/27 09:50:43 tale Exp $ */
2000-06-22 22:00:42 +00:00
1999-09-06 04:41:38 +00:00
#include <config.h>
#include <stddef.h>
1999-09-06 04:41:38 +00:00
#include <isc/buffer.h>
#include <isc/bufferlist.h>
2000-04-28 01:12:23 +00:00
#include <isc/util.h>
1999-09-06 04:41:38 +00:00
unsigned int
isc_bufferlist_usedcount(isc_bufferlist_t *bl) {
1999-09-06 04:41:38 +00:00
isc_buffer_t *buffer;
unsigned int length;
REQUIRE(bl != NULL);
length = 0;
buffer = ISC_LIST_HEAD(*bl);
while (buffer != NULL) {
REQUIRE(ISC_BUFFER_VALID(buffer));
length += isc_buffer_usedlength(buffer);
1999-09-06 04:41:38 +00:00
buffer = ISC_LIST_NEXT(buffer, link);
}
return (length);
}
unsigned int
isc_bufferlist_availablecount(isc_bufferlist_t *bl) {
1999-09-06 04:41:38 +00:00
isc_buffer_t *buffer;
unsigned int length;
REQUIRE(bl != NULL);
length = 0;
buffer = ISC_LIST_HEAD(*bl);
while (buffer != NULL) {
REQUIRE(ISC_BUFFER_VALID(buffer));
length += isc_buffer_availablelength(buffer);
1999-09-06 04:41:38 +00:00
buffer = ISC_LIST_NEXT(buffer, link);
}
return (length);
}