|
|
@ -176,18 +176,14 @@ uint32_t ByteBuffer::read(uint8_t *data, uint32_t len) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
return a pointer to a contiguous read buffer |
|
|
|
* Returns the pointer and size to a contiguous read in the buffer |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
const uint8_t *ByteBuffer::readptr(uint32_t &available_bytes) |
|
|
|
const uint8_t *ByteBuffer::readptr(uint32_t &available_bytes) |
|
|
|
{ |
|
|
|
{ |
|
|
|
available_bytes = available(); |
|
|
|
uint32_t _tail = tail; |
|
|
|
if (available_bytes == 0) { |
|
|
|
available_bytes = (head > _tail) ? size - head : _tail - head; |
|
|
|
return nullptr; |
|
|
|
|
|
|
|
} |
|
|
|
return available_bytes ? &buf[head] : nullptr; |
|
|
|
if (head+available_bytes > size) { |
|
|
|
|
|
|
|
available_bytes = size - head; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return &buf[head]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int16_t ByteBuffer::peek(uint32_t ofs) const |
|
|
|
int16_t ByteBuffer::peek(uint32_t ofs) const |
|
|
|