From c06bb51cdcb39b5b5c220639897ca17c69bc1d1f Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Tue, 2 Jul 2024 06:27:39 +0200 Subject: [PATCH] Driver code updated --- driver.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/driver.c b/driver.c index 8718d9f..0c4be14 100644 --- a/driver.c +++ b/driver.c @@ -16,16 +16,31 @@ main(void) int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int ok = WriteOk; // Assume we can write - for(int i = 0; i < 10 && ok == WriteOk; i++) { - ok = rb_push_back(&rb, &arr[i], memcpy); - } + ok = rb_push_many(&rb, arr, memcpy, 8); int d; - while(rb_pop_front(&rb, &d) == ReadOk) { + while(rb_pop_front(&rb, &d, memcpy) == ReadOk) { printf("Data: %d\n", d); } + // Test wrap around + rb_push_many(&rb, arr, memcpy, 10); + while(rb_pop_front(&rb, &d, memcpy) == ReadOk) { + printf("Data: %d\n", d); + } + + // Test clear + rb_clear(&rb); + if(rb_pop_front(&rb, &d, memcpy) != Empty) { + printf("Buffer is not empty after clear...\n"); + } + rb_destroy(&rb, free); + enum WriteResult wr = WriteOk; + enum ReadResult rr = ReadOk; + printf("Size of wr: %lu bytes.\n", sizeof(wr)); + printf("Size of rr: %lu bytes.\n", sizeof(rr)); + return 0; }