mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
add isc_buffer_{get,put}uint8
This commit is contained in:
@@ -277,6 +277,40 @@ isc_buffer_compact(isc_buffer_t *b) {
|
||||
b->used = length;
|
||||
}
|
||||
|
||||
isc_uint8_t
|
||||
isc_buffer_getuint8(isc_buffer_t *b) {
|
||||
unsigned char *cp;
|
||||
isc_uint8_t result;
|
||||
|
||||
/*
|
||||
* Read an unsigned 8-bit integer from 'b' and return it.
|
||||
*/
|
||||
|
||||
REQUIRE(VALID_BUFFER(b));
|
||||
REQUIRE(b->used - b->current >= 1);
|
||||
|
||||
cp = b->base;
|
||||
cp += b->current;
|
||||
b->current += 1;
|
||||
result = ((unsigned int)(cp[0]));
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
void
|
||||
isc_buffer_putuint8(isc_buffer_t *b, isc_uint8_t val)
|
||||
{
|
||||
unsigned char *cp;
|
||||
|
||||
REQUIRE(VALID_BUFFER(b));
|
||||
REQUIRE(b->used + 1 <= b->length);
|
||||
|
||||
cp = b->base;
|
||||
cp += b->used;
|
||||
b->used += 1;
|
||||
cp[0] = (val & 0x00ff);
|
||||
}
|
||||
|
||||
isc_uint16_t
|
||||
isc_buffer_getuint16(isc_buffer_t *b) {
|
||||
unsigned char *cp;
|
||||
|
Reference in New Issue
Block a user