|
|
|
@ -107,14 +107,17 @@ bool cbuf_push(CircBuf *cb, const void *source) |
|
|
|
|
/** Pop one element from the front_writepos */ |
|
|
|
|
bool cbuf_pop(CircBuf *cb, void *dest) |
|
|
|
|
{ |
|
|
|
|
if (cb == NULL || dest == NULL || cb->num_used == 0) { |
|
|
|
|
if (cb == NULL || cb->num_used == 0) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cb->num_used--; |
|
|
|
|
|
|
|
|
|
circbuf_size_t f = front_writepos(cb); |
|
|
|
|
read_buffer(cb, f, dest); |
|
|
|
|
|
|
|
|
|
if (dest != NULL) { |
|
|
|
|
read_buffer(cb, f, dest); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef CIRCBUF_ZERO_FREE_SLOTS |
|
|
|
|
memset(PV_OFFS(cb->buf, cb->elem_size, f), 0, cb->elem_size); |
|
|
|
@ -196,11 +199,13 @@ bool cbuf_push_back(CircBuf *cb, const void *source) |
|
|
|
|
/** Pop one element from the back */ |
|
|
|
|
bool cbuf_pop_back(CircBuf *cb, void *dest) |
|
|
|
|
{ |
|
|
|
|
if (cb == NULL || dest == NULL || cb->num_used == 0) { |
|
|
|
|
if (cb == NULL || cb->num_used == 0) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
read_buffer(cb, cb->back, dest); |
|
|
|
|
if (dest != NULL) { |
|
|
|
|
read_buffer(cb, cb->back, dest); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef CIRCBUF_ZERO_FREE_SLOTS |
|
|
|
|
memset(PV_OFFS(cb->buf, cb->elem_size, cb->back), 0, cb->elem_size); |
|
|
|
|