Hi, I'm implementing a circular buffer of variable-sized items with push and pop methods which I initialized like this:
For the implementation of the pop function I need to be able to check if the buffer is empty (no items) from the memory position pointed by the tail (wherever the tail is at that moment) to the end of the buffer. Does anyone have an idea of how I could do this? I would really appreciate any help
Code:
void *buffer = malloc(capacity);
if(buffer == NULL)
// handle error
void *buffer_end = (char *)buffer + capacity;
size_t capacity = capacity;
size_t count = 0;
void *head = buffer;
void *tail = buffer;
For the implementation of the pop function I need to be able to check if the buffer is empty (no items) from the memory position pointed by the tail (wherever the tail is at that moment) to the end of the buffer. Does anyone have an idea of how I could do this? I would really appreciate any help