bind9/lib/isc/bufferlist.c

56 lines
1.2 KiB
C
Raw Normal View History

1999-09-06 00:41:38 -04:00
/*
* Copyright (C) 1999-2001, 2004, 2005, 2007, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
1999-09-06 00:41:38 -04:00
*/
2007-06-19 19:47:24 -04:00
/* $Id: bufferlist.c,v 1.17 2007/06/19 23:47:17 tbox Exp $ */
/*! \file */
2000-06-22 18:00:42 -04:00
1999-09-06 00:41:38 -04:00
#include <config.h>
#include <stddef.h>
1999-09-06 00:41:38 -04:00
#include <isc/buffer.h>
#include <isc/bufferlist.h>
2000-04-27 21:12:23 -04:00
#include <isc/util.h>
1999-09-06 00:41:38 -04:00
unsigned int
isc_bufferlist_usedcount(isc_bufferlist_t *bl) {
1999-09-06 00:41:38 -04: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 00:41:38 -04:00
buffer = ISC_LIST_NEXT(buffer, link);
}
return (length);
}
unsigned int
isc_bufferlist_availablecount(isc_bufferlist_t *bl) {
1999-09-06 00:41:38 -04: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 00:41:38 -04:00
buffer = ISC_LIST_NEXT(buffer, link);
}
return (length);
}