2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 06:55:30 +00:00

add isc_buffer_copyregion

This commit is contained in:
Bob Halley
1999-09-22 00:35:59 +00:00
parent cdf3c7270e
commit cae6ddd340
2 changed files with 35 additions and 0 deletions

View File

@@ -384,6 +384,24 @@ isc_buffer_putuint32(isc_buffer_t *b, isc_uint32_t val)
cp[3] = (val & 0x000000ff);
}
isc_result_t
isc_buffer_copyregion(isc_buffer_t *b, isc_region_t *r) {
unsigned char *base;
unsigned int available;
REQUIRE(ISC_BUFFER_VALID(b));
REQUIRE(r != NULL);
base = (unsigned char *)b->base + b->used;
available = b->length - b->used;
if (r->length > available)
return (ISC_R_NOSPACE);
memcpy(base, r->base, r->length);
b->used += r->length;
return (ISC_R_SUCCESS);
}
isc_result_t
isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
unsigned int length, unsigned int type)