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

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.
Similar Threads
  1. Lord0
    Replies:
    1
    Views:
    901
    Thomas Weidenfeller
    Apr 19, 2006
  2. mshngo
    Replies:
    2
    Views:
    6,091
    Kanenas
    May 18, 2005
  3. Marcia Hon

    Check if a directory is empty and empty it

    Marcia Hon, Feb 8, 2004, in forum: C Programming
    Replies:
    8
    Views:
    1,030
    Dave Thompson
    Feb 14, 2004
  4. chiara
    Replies:
    6
    Views:
    870
    Barry Schwarz
    Oct 6, 2005
  5. 2Barter.net
    Replies:
    0
    Views:
    743
    2Barter.net
    Dec 13, 2006
  6. Casey Hawthorne
    Replies:
    385
    Views:
    9,033
    ng2010
    Apr 4, 2010
  7. Moh

    I need a VHDL code

    Moh, Jun 8, 2016, in forum: VHDL
    Replies:
    0
    Views:
    708
  8. ivan gagula

    VHDL sequence of a machine

    ivan gagula, Jun 22, 2016, in forum: Introductions
    Replies:
    0
    Views:
    508
    ivan gagula
    Jun 22, 2016
Loading...