From b567e5be3507f4a547e2212fee1820161c71070c Mon Sep 17 00:00:00 2001 From: Phillip Johnston Date: Mon, 1 Mar 2021 15:43:56 -0800 Subject: [PATCH] Update example to use full API instead of directly checkign full flag --- examples/c/circular_buffer/circular_buffer.c | 6 +++--- examples/c/circular_buffer/circular_buffer_no_modulo.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/c/circular_buffer/circular_buffer.c b/examples/c/circular_buffer/circular_buffer.c index 19b3027..9e78cd9 100644 --- a/examples/c/circular_buffer/circular_buffer.c +++ b/examples/c/circular_buffer/circular_buffer.c @@ -20,7 +20,7 @@ static void advance_pointer(cbuf_handle_t cbuf) { assert(cbuf); - if(cbuf->full) + if(circular_buf_full(cbuf)) { cbuf->tail = (cbuf->tail + 1) % cbuf->max; } @@ -78,7 +78,7 @@ size_t circular_buf_size(cbuf_handle_t cbuf) size_t size = cbuf->max; - if(!cbuf->full) + if(!circular_buf_full(cbuf)) { if(cbuf->head >= cbuf->tail) { @@ -147,7 +147,7 @@ bool circular_buf_empty(cbuf_handle_t cbuf) { assert(cbuf); - return (!cbuf->full && (cbuf->head == cbuf->tail)); + return (!circular_buf_full(cbuf) && (cbuf->head == cbuf->tail)); } bool circular_buf_full(cbuf_handle_t cbuf) diff --git a/examples/c/circular_buffer/circular_buffer_no_modulo.c b/examples/c/circular_buffer/circular_buffer_no_modulo.c index f34a5da..e9e2c96 100644 --- a/examples/c/circular_buffer/circular_buffer_no_modulo.c +++ b/examples/c/circular_buffer/circular_buffer_no_modulo.c @@ -20,7 +20,7 @@ static void advance_pointer(cbuf_handle_t cbuf) { assert(cbuf); - if(cbuf->full) + if(circular_buf_full(cbuf)) { if(++(cbuf->tail) == cbuf->max) { @@ -87,7 +87,7 @@ size_t circular_buf_size(cbuf_handle_t cbuf) size_t size = cbuf->max; - if(!cbuf->full) + if(!circular_buf_full(cbuf)) { if(cbuf->head >= cbuf->tail) { @@ -156,7 +156,7 @@ bool circular_buf_empty(cbuf_handle_t cbuf) { assert(cbuf); - return (!cbuf->full && (cbuf->head == cbuf->tail)); + return (!circular_buf_full(cbuf) && (cbuf->head == cbuf->tail)); } bool circular_buf_full(cbuf_handle_t cbuf)