Hi,
I'm trying to create a simple queue structure and am running into problems when I try to empty the queue. Here's the relevant pieces of code:
Code:
typedef struct queue_item {
void *item;
struct queue_item *next;
} q_item;
...
...
void GenericQueue::empty(q_item *i)
{
if (i != NULL) {
empty(i->next);
free(i);
}
}
It's all very simple but with Visual C++ I get an undefined heap error on the "free(i)" line. I thought I understood the basics of memory management but obviously not...can anyone point out my mistake?
Thanks,
Rob