I need to code a shared buffer (1R thread/1W thread) in C to asynchronously dump binary program output to I/O.
I normally use the classical circular buffer implementation when it comes to write a simple shared buffer, but in this case the size of each item on the buffer is variable and not-known at compile time.
I was wondering what is a possible implementation of a circular buffer with variable-sized items.
Thanks.
You may think of it as a circular binary stream. That is, instead if adding an element you’ll write the data, instead of popping it you’ll read it.