mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 15:45:25 +00:00
apply the modified style
This commit is contained in:
149
lib/isc/buffer.c
149
lib/isc/buffer.c
@@ -23,8 +23,7 @@
|
||||
#include <isc/util.h>
|
||||
|
||||
void
|
||||
isc__buffer_init(isc_buffer_t *b, void *base, unsigned int length)
|
||||
{
|
||||
isc__buffer_init(isc_buffer_t *b, void *base, unsigned int length) {
|
||||
/*
|
||||
* Make 'b' refer to the 'length'-byte region starting at 'base'.
|
||||
* XXXDCL see the comment in buffer.h about base being const.
|
||||
@@ -36,8 +35,7 @@ isc__buffer_init(isc_buffer_t *b, void *base, unsigned int length)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_initnull(isc_buffer_t *b)
|
||||
{
|
||||
isc__buffer_initnull(isc_buffer_t *b) {
|
||||
/*
|
||||
* Initialize a new buffer which has no backing store. This can
|
||||
* later be grown as needed and swapped in place.
|
||||
@@ -47,8 +45,7 @@ isc__buffer_initnull(isc_buffer_t *b)
|
||||
}
|
||||
|
||||
void
|
||||
isc_buffer_reinit(isc_buffer_t *b, void *base, unsigned int length)
|
||||
{
|
||||
isc_buffer_reinit(isc_buffer_t *b, void *base, unsigned int length) {
|
||||
/*
|
||||
* Re-initialize the buffer enough to reconfigure the base of the
|
||||
* buffer. We will swap in the new buffer, after copying any
|
||||
@@ -71,8 +68,7 @@ isc_buffer_reinit(isc_buffer_t *b, void *base, unsigned int length)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_invalidate(isc_buffer_t *b)
|
||||
{
|
||||
isc__buffer_invalidate(isc_buffer_t *b) {
|
||||
/*
|
||||
* Make 'b' an invalid buffer.
|
||||
*/
|
||||
@@ -85,16 +81,14 @@ isc__buffer_invalidate(isc_buffer_t *b)
|
||||
}
|
||||
|
||||
void
|
||||
isc_buffer_setautorealloc(isc_buffer_t *b, bool enable)
|
||||
{
|
||||
isc_buffer_setautorealloc(isc_buffer_t *b, bool enable) {
|
||||
REQUIRE(ISC_BUFFER_VALID(b));
|
||||
REQUIRE(b->mctx != NULL);
|
||||
b->autore = enable;
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_region(isc_buffer_t *b, isc_region_t *r)
|
||||
{
|
||||
isc__buffer_region(isc_buffer_t *b, isc_region_t *r) {
|
||||
/*
|
||||
* Make 'r' refer to the region of 'b'.
|
||||
*/
|
||||
@@ -106,8 +100,7 @@ isc__buffer_region(isc_buffer_t *b, isc_region_t *r)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_usedregion(const isc_buffer_t *b, isc_region_t *r)
|
||||
{
|
||||
isc__buffer_usedregion(const isc_buffer_t *b, isc_region_t *r) {
|
||||
/*
|
||||
* Make 'r' refer to the used region of 'b'.
|
||||
*/
|
||||
@@ -119,8 +112,7 @@ isc__buffer_usedregion(const isc_buffer_t *b, isc_region_t *r)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_availableregion(isc_buffer_t *b, isc_region_t *r)
|
||||
{
|
||||
isc__buffer_availableregion(isc_buffer_t *b, isc_region_t *r) {
|
||||
/*
|
||||
* Make 'r' refer to the available region of 'b'.
|
||||
*/
|
||||
@@ -132,8 +124,7 @@ isc__buffer_availableregion(isc_buffer_t *b, isc_region_t *r)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_add(isc_buffer_t *b, unsigned int n)
|
||||
{
|
||||
isc__buffer_add(isc_buffer_t *b, unsigned int n) {
|
||||
/*
|
||||
* Increase the 'used' region of 'b' by 'n' bytes.
|
||||
*/
|
||||
@@ -145,8 +136,7 @@ isc__buffer_add(isc_buffer_t *b, unsigned int n)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_subtract(isc_buffer_t *b, unsigned int n)
|
||||
{
|
||||
isc__buffer_subtract(isc_buffer_t *b, unsigned int n) {
|
||||
/*
|
||||
* Decrease the 'used' region of 'b' by 'n' bytes.
|
||||
*/
|
||||
@@ -158,8 +148,7 @@ isc__buffer_subtract(isc_buffer_t *b, unsigned int n)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_clear(isc_buffer_t *b)
|
||||
{
|
||||
isc__buffer_clear(isc_buffer_t *b) {
|
||||
/*
|
||||
* Make the used region empty.
|
||||
*/
|
||||
@@ -170,8 +159,7 @@ isc__buffer_clear(isc_buffer_t *b)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_consumedregion(isc_buffer_t *b, isc_region_t *r)
|
||||
{
|
||||
isc__buffer_consumedregion(isc_buffer_t *b, isc_region_t *r) {
|
||||
/*
|
||||
* Make 'r' refer to the consumed region of 'b'.
|
||||
*/
|
||||
@@ -183,8 +171,7 @@ isc__buffer_consumedregion(isc_buffer_t *b, isc_region_t *r)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_remainingregion(isc_buffer_t *b, isc_region_t *r)
|
||||
{
|
||||
isc__buffer_remainingregion(isc_buffer_t *b, isc_region_t *r) {
|
||||
/*
|
||||
* Make 'r' refer to the remaining region of 'b'.
|
||||
*/
|
||||
@@ -196,8 +183,7 @@ isc__buffer_remainingregion(isc_buffer_t *b, isc_region_t *r)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_activeregion(isc_buffer_t *b, isc_region_t *r)
|
||||
{
|
||||
isc__buffer_activeregion(isc_buffer_t *b, isc_region_t *r) {
|
||||
/*
|
||||
* Make 'r' refer to the active region of 'b'.
|
||||
*/
|
||||
@@ -209,8 +195,7 @@ isc__buffer_activeregion(isc_buffer_t *b, isc_region_t *r)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_setactive(isc_buffer_t *b, unsigned int n)
|
||||
{
|
||||
isc__buffer_setactive(isc_buffer_t *b, unsigned int n) {
|
||||
/*
|
||||
* Sets the end of the active region 'n' bytes after current.
|
||||
*/
|
||||
@@ -222,8 +207,7 @@ isc__buffer_setactive(isc_buffer_t *b, unsigned int n)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_first(isc_buffer_t *b)
|
||||
{
|
||||
isc__buffer_first(isc_buffer_t *b) {
|
||||
/*
|
||||
* Make the consumed region empty.
|
||||
*/
|
||||
@@ -234,8 +218,7 @@ isc__buffer_first(isc_buffer_t *b)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_forward(isc_buffer_t *b, unsigned int n)
|
||||
{
|
||||
isc__buffer_forward(isc_buffer_t *b, unsigned int n) {
|
||||
/*
|
||||
* Increase the 'consumed' region of 'b' by 'n' bytes.
|
||||
*/
|
||||
@@ -247,8 +230,7 @@ isc__buffer_forward(isc_buffer_t *b, unsigned int n)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_back(isc_buffer_t *b, unsigned int n)
|
||||
{
|
||||
isc__buffer_back(isc_buffer_t *b, unsigned int n) {
|
||||
/*
|
||||
* Decrease the 'consumed' region of 'b' by 'n' bytes.
|
||||
*/
|
||||
@@ -260,10 +242,9 @@ isc__buffer_back(isc_buffer_t *b, unsigned int n)
|
||||
}
|
||||
|
||||
void
|
||||
isc_buffer_compact(isc_buffer_t *b)
|
||||
{
|
||||
isc_buffer_compact(isc_buffer_t *b) {
|
||||
unsigned int length;
|
||||
void * src;
|
||||
void *src;
|
||||
|
||||
/*
|
||||
* Compact the used region by moving the remaining region so it occurs
|
||||
@@ -289,10 +270,9 @@ isc_buffer_compact(isc_buffer_t *b)
|
||||
}
|
||||
|
||||
uint8_t
|
||||
isc_buffer_getuint8(isc_buffer_t *b)
|
||||
{
|
||||
isc_buffer_getuint8(isc_buffer_t *b) {
|
||||
unsigned char *cp;
|
||||
uint8_t result;
|
||||
uint8_t result;
|
||||
|
||||
/*
|
||||
* Read an unsigned 8-bit integer from 'b' and return it.
|
||||
@@ -309,8 +289,7 @@ isc_buffer_getuint8(isc_buffer_t *b)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_putuint8(isc_buffer_t *b, uint8_t val)
|
||||
{
|
||||
isc__buffer_putuint8(isc_buffer_t *b, uint8_t val) {
|
||||
isc_result_t result;
|
||||
REQUIRE(ISC_BUFFER_VALID(b));
|
||||
if (ISC_UNLIKELY(b->autore)) {
|
||||
@@ -323,10 +302,9 @@ isc__buffer_putuint8(isc_buffer_t *b, uint8_t val)
|
||||
}
|
||||
|
||||
uint16_t
|
||||
isc_buffer_getuint16(isc_buffer_t *b)
|
||||
{
|
||||
isc_buffer_getuint16(isc_buffer_t *b) {
|
||||
unsigned char *cp;
|
||||
uint16_t result;
|
||||
uint16_t result;
|
||||
|
||||
/*
|
||||
* Read an unsigned 16-bit integer in network byte order from 'b',
|
||||
@@ -345,8 +323,7 @@ isc_buffer_getuint16(isc_buffer_t *b)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_putuint16(isc_buffer_t *b, uint16_t val)
|
||||
{
|
||||
isc__buffer_putuint16(isc_buffer_t *b, uint16_t val) {
|
||||
isc_result_t result;
|
||||
REQUIRE(ISC_BUFFER_VALID(b));
|
||||
if (ISC_UNLIKELY(b->autore)) {
|
||||
@@ -359,8 +336,7 @@ isc__buffer_putuint16(isc_buffer_t *b, uint16_t val)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_putuint24(isc_buffer_t *b, uint32_t val)
|
||||
{
|
||||
isc__buffer_putuint24(isc_buffer_t *b, uint32_t val) {
|
||||
isc_result_t result;
|
||||
REQUIRE(ISC_BUFFER_VALID(b));
|
||||
if (ISC_UNLIKELY(b->autore)) {
|
||||
@@ -373,10 +349,9 @@ isc__buffer_putuint24(isc_buffer_t *b, uint32_t val)
|
||||
}
|
||||
|
||||
uint32_t
|
||||
isc_buffer_getuint32(isc_buffer_t *b)
|
||||
{
|
||||
isc_buffer_getuint32(isc_buffer_t *b) {
|
||||
unsigned char *cp;
|
||||
uint32_t result;
|
||||
uint32_t result;
|
||||
|
||||
/*
|
||||
* Read an unsigned 32-bit integer in network byte order from 'b',
|
||||
@@ -397,8 +372,7 @@ isc_buffer_getuint32(isc_buffer_t *b)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_putuint32(isc_buffer_t *b, uint32_t val)
|
||||
{
|
||||
isc__buffer_putuint32(isc_buffer_t *b, uint32_t val) {
|
||||
isc_result_t result;
|
||||
REQUIRE(ISC_BUFFER_VALID(b));
|
||||
if (ISC_UNLIKELY(b->autore)) {
|
||||
@@ -411,10 +385,9 @@ isc__buffer_putuint32(isc_buffer_t *b, uint32_t val)
|
||||
}
|
||||
|
||||
uint64_t
|
||||
isc_buffer_getuint48(isc_buffer_t *b)
|
||||
{
|
||||
isc_buffer_getuint48(isc_buffer_t *b) {
|
||||
unsigned char *cp;
|
||||
uint64_t result;
|
||||
uint64_t result;
|
||||
|
||||
/*
|
||||
* Read an unsigned 48-bit integer in network byte order from 'b',
|
||||
@@ -437,11 +410,10 @@ isc_buffer_getuint48(isc_buffer_t *b)
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_putuint48(isc_buffer_t *b, uint64_t val)
|
||||
{
|
||||
isc__buffer_putuint48(isc_buffer_t *b, uint64_t val) {
|
||||
isc_result_t result;
|
||||
uint16_t valhi;
|
||||
uint32_t vallo;
|
||||
uint16_t valhi;
|
||||
uint32_t vallo;
|
||||
|
||||
REQUIRE(ISC_BUFFER_VALID(b));
|
||||
if (ISC_UNLIKELY(b->autore)) {
|
||||
@@ -458,8 +430,7 @@ isc__buffer_putuint48(isc_buffer_t *b, uint64_t val)
|
||||
|
||||
void
|
||||
isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base,
|
||||
unsigned int length)
|
||||
{
|
||||
unsigned int length) {
|
||||
isc_result_t result;
|
||||
REQUIRE(ISC_BUFFER_VALID(b));
|
||||
if (ISC_UNLIKELY(b->autore)) {
|
||||
@@ -472,11 +443,10 @@ isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base,
|
||||
}
|
||||
|
||||
void
|
||||
isc__buffer_putstr(isc_buffer_t *b, const char *source)
|
||||
{
|
||||
unsigned int l;
|
||||
isc__buffer_putstr(isc_buffer_t *b, const char *source) {
|
||||
unsigned int l;
|
||||
unsigned char *cp;
|
||||
isc_result_t result;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(ISC_BUFFER_VALID(b));
|
||||
REQUIRE(source != NULL);
|
||||
@@ -497,12 +467,11 @@ isc__buffer_putstr(isc_buffer_t *b, const char *source)
|
||||
}
|
||||
|
||||
void
|
||||
isc_buffer_putdecint(isc_buffer_t *b, int64_t v)
|
||||
{
|
||||
unsigned int l = 0;
|
||||
isc_buffer_putdecint(isc_buffer_t *b, int64_t v) {
|
||||
unsigned int l = 0;
|
||||
unsigned char *cp;
|
||||
char buf[21];
|
||||
isc_result_t result;
|
||||
char buf[21];
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(ISC_BUFFER_VALID(b));
|
||||
|
||||
@@ -521,11 +490,10 @@ isc_buffer_putdecint(isc_buffer_t *b, int64_t v)
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_buffer_dup(isc_mem_t *mctx, isc_buffer_t **dstp, const isc_buffer_t *src)
|
||||
{
|
||||
isc_buffer_dup(isc_mem_t *mctx, isc_buffer_t **dstp, const isc_buffer_t *src) {
|
||||
isc_buffer_t *dst = NULL;
|
||||
isc_region_t region;
|
||||
isc_result_t result;
|
||||
isc_region_t region;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(dstp != NULL && *dstp == NULL);
|
||||
REQUIRE(ISC_BUFFER_VALID(src));
|
||||
@@ -541,8 +509,7 @@ isc_buffer_dup(isc_mem_t *mctx, isc_buffer_t **dstp, const isc_buffer_t *src)
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r)
|
||||
{
|
||||
isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r) {
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(ISC_BUFFER_VALID(b));
|
||||
@@ -569,11 +536,10 @@ isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r)
|
||||
|
||||
void
|
||||
isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
|
||||
unsigned int length)
|
||||
{
|
||||
unsigned int length) {
|
||||
REQUIRE(dynbuffer != NULL && *dynbuffer == NULL);
|
||||
|
||||
isc_buffer_t * dbuf = isc_mem_get(mctx, sizeof(isc_buffer_t));
|
||||
isc_buffer_t *dbuf = isc_mem_get(mctx, sizeof(isc_buffer_t));
|
||||
unsigned char *bdata = isc_mem_get(mctx, length);
|
||||
|
||||
isc_buffer_init(dbuf, bdata, length);
|
||||
@@ -586,10 +552,9 @@ isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_buffer_reserve(isc_buffer_t **dynbuffer, unsigned int size)
|
||||
{
|
||||
isc_buffer_reserve(isc_buffer_t **dynbuffer, unsigned int size) {
|
||||
unsigned char *bdata;
|
||||
uint64_t len;
|
||||
uint64_t len;
|
||||
|
||||
REQUIRE(dynbuffer != NULL);
|
||||
REQUIRE(ISC_BUFFER_VALID(*dynbuffer));
|
||||
@@ -634,10 +599,9 @@ isc_buffer_reserve(isc_buffer_t **dynbuffer, unsigned int size)
|
||||
}
|
||||
|
||||
void
|
||||
isc_buffer_free(isc_buffer_t **dynbuffer)
|
||||
{
|
||||
isc_buffer_free(isc_buffer_t **dynbuffer) {
|
||||
isc_buffer_t *dbuf;
|
||||
isc_mem_t * mctx;
|
||||
isc_mem_t *mctx;
|
||||
|
||||
REQUIRE(dynbuffer != NULL);
|
||||
REQUIRE(ISC_BUFFER_VALID(*dynbuffer));
|
||||
@@ -654,10 +618,9 @@ isc_buffer_free(isc_buffer_t **dynbuffer)
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_buffer_printf(isc_buffer_t *b, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int n;
|
||||
isc_buffer_printf(isc_buffer_t *b, const char *format, ...) {
|
||||
va_list ap;
|
||||
int n;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(ISC_BUFFER_VALID(b));
|
||||
|
Reference in New Issue
Block a user