I am implementing a queue with a linked list which is going to have data that will be send and received in the same program with simple commands and I want to add a counter to each data in the queue, values being new, pending or ack. So do I store it in an array or is there any other way because the number of counters will be huge?
#define TOTALPACKETS 100
#define WINDOW 5
#define ACK 2
#define PENDING 1
#define NEW 0
typedef int Item ;
typedef struct node *link;
struct node{
Item data;
Item status;
link next;
};
int QUEUEempty(link head){
return head==NULL;
}
void QUEUEput(link *head, link *tail, Item data, Item status){
if (*head==NULL){
(*tail)=(link)malloc(sizeof(node));
(*tail)->data=data;
(*tail)->next=NULL;
(*tail)->status=NEW;
*head=*tail;
return;}
(*tail)->next=(link)malloc(sizeof(node));
*tail=(*tail)->next;
(*tail)->data=data;
(*tail)->next=NULL;
(*tail)->status=NEW;
return;
}
Item QUEUEget(link *head){
Item data=(*head)->data;
Item status
link t=*head;
*head=(*head)->next;
free(t);
return data;
}