I'm trying to implement a queue and for dequeue I've purposely done with an int procedure. What would be possible drawbacks for using an int?
int dequeue(queue *q) {
int res = 0; // list not empty
node *tmp = NULL;
if (q->first != res) {
tmp = q->first->next; // store the value after the first one
free(q->first);
q->first = tmp;
}
free(tmp);
return res;
}
I was thinking if it could it be that maybe that position already has 0 and that we cannot be sure that it's "not empty"?
But then it's never safe to use an int to determine whether it is empty or not?