mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 18:13:49 +01:00
sys/chunked_ringbuffer: let crb_end_chunk() return size of the chunk
This commit is contained in:
parent
139404df35
commit
3429621911
@ -87,13 +87,13 @@ static unsigned _get_cur_len(chunk_ringbuf_t *rb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool crb_end_chunk(chunk_ringbuf_t *rb, bool keep)
|
unsigned crb_end_chunk(chunk_ringbuf_t *rb, bool keep)
|
||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
/* no chunk was started */
|
/* no chunk was started */
|
||||||
if (rb->cur_start == NULL) {
|
if (rb->cur_start == NULL) {
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keep) {
|
if (keep) {
|
||||||
@ -109,7 +109,7 @@ bool crb_end_chunk(chunk_ringbuf_t *rb, bool keep)
|
|||||||
}
|
}
|
||||||
rb->cur = rb->cur_start;
|
rb->cur = rb->cur_start;
|
||||||
rb->cur_start = NULL;
|
rb->cur_start = NULL;
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store complete chunk */
|
/* store complete chunk */
|
||||||
@ -117,7 +117,7 @@ bool crb_end_chunk(chunk_ringbuf_t *rb, bool keep)
|
|||||||
rb->chunk_len[idx] = _get_cur_len(rb);
|
rb->chunk_len[idx] = _get_cur_len(rb);
|
||||||
rb->cur_start = NULL;
|
rb->cur_start = NULL;
|
||||||
|
|
||||||
return true;
|
return rb->chunk_len[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool crb_get_chunk_size(chunk_ringbuf_t *rb, size_t *len)
|
bool crb_get_chunk_size(chunk_ringbuf_t *rb, size_t *len)
|
||||||
|
|||||||
@ -82,10 +82,10 @@ void crb_init(chunk_ringbuf_t *rb, void *buffer, size_t len);
|
|||||||
* @param[in] valid True if the chunk is valid and should be stored
|
* @param[in] valid True if the chunk is valid and should be stored
|
||||||
* False if the current chunk should be discarded
|
* False if the current chunk should be discarded
|
||||||
*
|
*
|
||||||
* @return true If the chunk could be stored in the valid chunk array
|
* @return size of chunk if the chunk could be stored in the valid chunk array
|
||||||
* @return false If there is no more space in the valid chunk array
|
* @return 0 if there is no more space in the valid chunk array
|
||||||
*/
|
*/
|
||||||
bool crb_end_chunk(chunk_ringbuf_t *rb, bool valid);
|
unsigned crb_end_chunk(chunk_ringbuf_t *rb, bool valid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Start a new chunk on the ringbuffer
|
* @brief Start a new chunk on the ringbuffer
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user