mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-10 09:58:28 -04:00
AP_HAL: added set_size() to RingBuffer API
This commit is contained in:
parent
eb4707f65c
commit
595d5c0002
@ -18,6 +18,18 @@ ByteBuffer::~ByteBuffer(void)
|
|||||||
delete [] buf;
|
delete [] buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
caller is responsible for locking in set_size()
|
||||||
|
*/
|
||||||
|
void ByteBuffer::set_size(uint32_t _size)
|
||||||
|
{
|
||||||
|
uint8_t *oldbuf = buf;
|
||||||
|
head = tail = 0;
|
||||||
|
size = _size;
|
||||||
|
buf = new uint8_t[size];
|
||||||
|
delete [] oldbuf;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t ByteBuffer::available(void) const
|
uint32_t ByteBuffer::available(void) const
|
||||||
{
|
{
|
||||||
uint32_t _tail;
|
uint32_t _tail;
|
||||||
|
@ -55,6 +55,9 @@ public:
|
|||||||
// return size of ringbuffer
|
// return size of ringbuffer
|
||||||
uint32_t get_size(void) const { return size; }
|
uint32_t get_size(void) const { return size; }
|
||||||
|
|
||||||
|
// set size of ringbuffer, caller responsible for locking
|
||||||
|
void set_size(uint32_t size);
|
||||||
|
|
||||||
// advance the read pointer (discarding bytes)
|
// advance the read pointer (discarding bytes)
|
||||||
bool advance(uint32_t n);
|
bool advance(uint32_t n);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user