Skip to content

Instantly share code, notes, and snippets.

@MarkyC
Created May 6, 2013 13:42
Show Gist options
  • Select an option

  • Save MarkyC/5525231 to your computer and use it in GitHub Desktop.

Select an option

Save MarkyC/5525231 to your computer and use it in GitHub Desktop.
typedef struct Node Node;
typedef struct FIFOQ FIFOQ;
struct Node {
char data; // the data for this Node
off_t offset; // offset of data byte in the file
Node *next; // next Node in the queue
};
struct FIFOQ {
Node *head; // first Node in the queue
Node *tail; // last Node in the queue
int size; // number of Nodes
};
......
/** Pops the top Node. Returns NULL if queue is empty */
Node * q_pop (FIFOQ *q) {
if (q->size <= 0) return NULL; // return null if empty queue
Node * result = q->head; // remove head Node
q->head = q->head->next; // set new head to the next in line
q->size--; // decrement size
return result; // return old head Node
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment