Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/ntp/lib/isc/buffer.c
Show First 20 Lines • Show All 400 Lines • ▼ Show 20 Lines | isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base, | ||||
REQUIRE(ISC_BUFFER_VALID(b)); | REQUIRE(ISC_BUFFER_VALID(b)); | ||||
REQUIRE(b->used + length <= b->length); | REQUIRE(b->used + length <= b->length); | ||||
ISC__BUFFER_PUTMEM(b, base, length); | ISC__BUFFER_PUTMEM(b, base, length); | ||||
} | } | ||||
void | void | ||||
isc__buffer_putstr(isc_buffer_t *b, const char *source) { | isc__buffer_putstr(isc_buffer_t *b, const char *source) { | ||||
unsigned int l; | size_t l; | ||||
unsigned char *cp; | unsigned char *cp; | ||||
REQUIRE(ISC_BUFFER_VALID(b)); | REQUIRE(ISC_BUFFER_VALID(b)); | ||||
REQUIRE(source != NULL); | REQUIRE(source != NULL); | ||||
/* | /* | ||||
* Do not use ISC__BUFFER_PUTSTR(), so strlen is only done once. | * Do not use ISC__BUFFER_PUTSTR(), so strlen is only done once. | ||||
*/ | */ | ||||
l = strlen(source); | l = strlen(source); | ||||
REQUIRE(l <= isc_buffer_availablelength(b)); | REQUIRE(l <= isc_buffer_availablelength(b)); | ||||
cp = isc_buffer_used(b); | cp = isc_buffer_used(b); | ||||
memcpy(cp, source, l); | memcpy(cp, source, l); | ||||
b->used += l; | b->used += (u_int)l; /* checked above - no overflow here */ | ||||
} | } | ||||
isc_result_t | 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) { | ||||
unsigned char *base; | unsigned char *base; | ||||
unsigned int available; | unsigned int available; | ||||
REQUIRE(ISC_BUFFER_VALID(b)); | REQUIRE(ISC_BUFFER_VALID(b)); | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |