Add isc_buffer_putstr().
This commit is contained in:
@@ -397,6 +397,23 @@ isc_buffer_putmem(isc_buffer_t *b, unsigned char *base, unsigned int length)
|
||||
b->used += length;
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_buffer_putstr(isc_buffer_t *b, const char *source) {
|
||||
unsigned int l;
|
||||
isc_region_t region;
|
||||
|
||||
REQUIRE(ISC_BUFFER_VALID(b));
|
||||
REQUIRE(source != NULL);
|
||||
|
||||
l = strlen(source);
|
||||
if (l > (b->length - b->used))
|
||||
return (ISC_R_NOSPACE);
|
||||
|
||||
memcpy(b->base + b->used, source, l);
|
||||
b->used += l;
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_buffer_copyregion(isc_buffer_t *b, isc_region_t *r) {
|
||||
unsigned char *base;
|
||||
|
||||
@@ -549,6 +549,18 @@ isc_buffer_putmem(isc_buffer_t *b, unsigned char *base, unsigned int length);
|
||||
*
|
||||
* 'base' points to 'length' bytes of valid memory.
|
||||
*
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_buffer_putstr(isc_buffer_t *b, const char *source);
|
||||
/*
|
||||
* Copy 'length' bytes of memory at 'base' into 'b'.
|
||||
*
|
||||
* Requires:
|
||||
* 'b' is a valid buffer.
|
||||
*
|
||||
* 'source' to be a valid NULL terminated string.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* ISC_R_SUCCESS
|
||||
|
||||
Reference in New Issue
Block a user