July 2015
Intermediate to advanced
380 pages
10h 15m
English
Ring buffers are incredibly useful when processing asynchronous I/O. They allow one side to receive data in random intervals of random sizes, but feed cohesive chunks to another side in set sizes or intervals. They are a variant on the Queue data structure but focus on blocks of bytes instead of a list of pointers. In this exercise, I’m going to show you the RingBuffer code, and then have you make a full unit test for it.
ringbuffer.h
1 #ifndef _lcthw_RingBuffer_h 2 #define _lcthw_RingBuffer_h 3 4 #include <lcthw/bstrlib.h> 5 6 typedef struct { 7 char *buffer; 8 int length; 9 int start; 10 int end; 11 } RingBuffer; 12 13 RingBuffer ...