I am trying to make my queue library and when I implement the dequeue method, an exception is throw "0xC0000374: A heap has been corrupted (parameters: 0x77475910)." This only gets thrown AFTER I already remove an item from the queue, the item is returned successfully however the first element is not removed, here is how I wrote the code :
typedef struct {
int value;
struct queue_item * next;
} queue_item;
typedef queue_item * queue;
and this is the method:
int dequeue(queue q)
{
queue fi = q;
int value = q->value;
fi = q;
q = q->next;
free(fi);
return value;
}