Check if buffer is empty from a given position

Discussion in 'C Programming' started by alxcam8, Jun 29, 2016.

  1. alxcam8

    alxcam8

    Joined:
    Jun 29, 2016
    Messages:
    1
    Likes Received:
    0
    Hi, I'm implementing a circular buffer of variable-sized items with push and pop methods which I initialized like this:
    Code (Text):
     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
     
    alxcam8, Jun 29, 2016
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.