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?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lord0
    Replies:
    1
    Views:
    835
    Thomas Weidenfeller
    Apr 19, 2006
  2. mshngo
    Replies:
    2
    Views:
    5,573
    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:
    973
    Dave Thompson
    Feb 14, 2004
  4. chiara
    Replies:
    6
    Views:
    820
    Barry Schwarz
    Oct 6, 2005
  5. 2Barter.net
    Replies:
    0
    Views:
    673
    2Barter.net
    Dec 13, 2006
  6. Casey Hawthorne
    Replies:
    385
    Views:
    8,566
    ng2010
    Apr 4, 2010
  7. Moh

    I need a VHDL code

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

    VHDL sequence of a machine

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