Skip to content

Commit 3429621

Browse files
committed
sys/chunked_ringbuffer: let crb_end_chunk() return size of the chunk
1 parent 139404d commit 3429621

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

sys/chunked_ringbuffer/chunked_ringbuffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ static unsigned _get_cur_len(chunk_ringbuf_t *rb)
8787
}
8888
}
8989

90-
bool crb_end_chunk(chunk_ringbuf_t *rb, bool keep)
90+
unsigned crb_end_chunk(chunk_ringbuf_t *rb, bool keep)
9191
{
9292
int idx;
9393

9494
/* no chunk was started */
9595
if (rb->cur_start == NULL) {
96-
return false;
96+
return 0;
9797
}
9898

9999
if (keep) {
@@ -109,15 +109,15 @@ bool crb_end_chunk(chunk_ringbuf_t *rb, bool keep)
109109
}
110110
rb->cur = rb->cur_start;
111111
rb->cur_start = NULL;
112-
return false;
112+
return 0;
113113
}
114114

115115
/* store complete chunk */
116116
rb->chunk_start[idx] = rb->cur_start;
117117
rb->chunk_len[idx] = _get_cur_len(rb);
118118
rb->cur_start = NULL;
119119

120-
return true;
120+
return rb->chunk_len[idx];
121121
}
122122

123123
bool crb_get_chunk_size(chunk_ringbuf_t *rb, size_t *len)

sys/include/chunked_ringbuffer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ void crb_init(chunk_ringbuf_t *rb, void *buffer, size_t len);
8282
* @param[in] valid True if the chunk is valid and should be stored
8383
* False if the current chunk should be discarded
8484
*
85-
* @return true If the chunk could be stored in the valid chunk array
86-
* @return false If there is no more space in the valid chunk array
85+
* @return size of chunk if the chunk could be stored in the valid chunk array
86+
* @return 0 if there is no more space in the valid chunk array
8787
*/
88-
bool crb_end_chunk(chunk_ringbuf_t *rb, bool valid);
88+
unsigned crb_end_chunk(chunk_ringbuf_t *rb, bool valid);
8989

9090
/**
9191
* @brief Start a new chunk on the ringbuffer

0 commit comments

Comments
 (0)