Check if buffer is empty from a given position

Joined
Jun 29, 2016
Messages
1
Reaction score
0
Hi, I'm implementing a circular buffer of variable-sized items with push and pop methods which I initialized like this:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top