aimdharma wrote:
int display()
{
temp=(queue*)malloc(sizeof(struct queue)*1024);
//realloc(temp,sizeof(queue));
temp=front;
printf("i am ready\n");
while(temp!=NULL)
{
printf("%d\t",temp->data);
temp=temp->next;
}
free(temp);
return 0;
}
This function is broken, since inner (useless) allocated memory is never released.
At the end of the loop,
temp
is NULL.
Remove both the
temp=(queue*)malloc(sizeof(struct queue)*1024);
and the
free(temp);
line.