Commit 8a21ac0f authored by Mark Andrews's avatar Mark Andrews
Browse files

Add isc_buffer_putstr().

parent e8cf926e
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment