Aug 28, 2011 at 7:26am UTC
Nothing has been initialized. Not in the code you posted anyway..
Aug 28, 2011 at 12:12pm UTC
This is the initialization part for H_queue (H_queue being a double linked list). Other queues has a similar initialization process
H_queue_H= (struct queue *)malloc(max_QH_H*sizeof (struct queue));
memset(H_queue_H, 0, max_QH_H*sizeof(struct queue));
H_queue_head_H= H_queue_H;
for (i=0; i< max_QH_H-1; i++)
H_queue_H[i].next=H_queue_H+i+1;
H_queue_H[max_QH_H-i-1].next=(struct queue *) NULL;
H_queue_head_H = H_queue_tail_H=(struct queue *) NULL;
H_queue_empty_H=H_queue_H;
Aug 28, 2011 at 1:03pm UTC
Still, this sounds like uninitialized pointer.
Try making line 25, queue *H_queue_empty_H = 0;
, and adding printf("H_queue_empty_H is at %p\n" , H_queue_empty_H);
immediately after initialization and before line 38, to see if that pointer is initialized and if it isn't corrupted.
Last edited on Aug 28, 2011 at 1:03pm UTC
Aug 28, 2011 at 7:11pm UTC
It turned out that the linked list was not intialized properly
The main error is this line:
H_queue_H[max_QH_H-i-1].next=(struct queue *) NULL;
When I exit for loop, I was setting first element's next field to NULL while I should have set the last one instead!
Thanks hamsterman :)