mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
add isc_buffer_copyregion
This commit is contained in:
parent
cdf3c7270e
commit
cae6ddd340
@ -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)
|
||||
|
@ -539,6 +539,23 @@ isc_buffer_putuint32(isc_buffer_t *b, isc_uint32_t val);
|
||||
* The used pointer in 'b' is advanced by 4.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_buffer_copyregion(isc_buffer_t *b, isc_region_t *r);
|
||||
/*
|
||||
* Copy the contents of 'r' into 'b'.
|
||||
*
|
||||
* Requires:
|
||||
* 'b' is a valid buffer.
|
||||
*
|
||||
* 'r' is a valid region.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* ISC_R_SUCCESS
|
||||
* ISC_R_NOSPACE The available region of 'b' is not
|
||||
* big enough.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_BUFFER_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user