-
August 27th, 2011, 04:37 PM
#1
C++ access violation exception?
Hi all
For the following code I keep getting an access violation exception but i'am not sure why. the expection seems to disappear when the size of the queue is one. queue being a single linked list:
{
b=H_queue_empty_H;
H_queue_empty_H=H_queue_empty_H->next; // THE EXCECPION APPEARS HERE
b->start=currentTime;
b->duration= currentTime +GenExpRV(mewHwait_H);
if(H_queue_tail_H!=(queue *)NULL)
{
H_queue_tail_H->next=b;
b->prev=H_queue_tail_H;
b->next = (queue *)NULL;
H_queue_tail_H=b;
}
So guys what do you think might be the problem?
Any suggestions plz
-
August 27th, 2011, 06:48 PM
#2
Re: C++ access violation exception?
H_queue_empty_H is null or invalid.
-
August 28th, 2011, 05:41 AM
#3
Re: C++ access violation exception?
-
August 28th, 2011, 02:12 PM
#4
Re: C++ access violation exception?
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 guys
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|