class QUEUE
{
public:
QUEUE();
~QUEUE();
void AddEvent(EVENT*); // Adds event to the queue
EVENT* PopEvent(void); // Removes and returns next item in queue
private:
EVENT* Next; //Pointer to first item in queue
};
EVENT* QUEUE::PopEvent()
{
Event("Queue: Event popping * ");
EVENT* CurrEvent; // keep pointer to first item in queue
Event("Queue: Pointer ready * ");
// PROGRAM STOPS COLD AND DUMPS BACK TO WINDOWS AFTER THIS POINT
if(Next == 0) Event("Next is NULL * ");
if(Next != 0) Event("Next is not NULL * ");
Event("Queue: Survived Test * ");
CurrEvent = Next;
Event("Queue: Event Acquired * ");
Next = CurrEvent->NextEvent; // advance the queue, which drops the first item
Event("Queue: Queue Advanced * ");
return CurrEvent; // return the dropped first item
}
All the Event crap is just spitting text to a file so I know exactly where the program stopped. Problem is, the program seems to stop as soon as Next is referenced. Originally, the CurrEvent = Next; line was dropping the program, but now also the if statements fail. And I haven''t the slightest clue why. Both QUEUE constructor and AddEvent work properly. Only PopEvent does this.
Help? Please?
Radhil Trebors
Persona Under Construction
Nope, that's not it. Tried it, just to be sure, but program still stops at the same point. The IF statements weren't the original crash point anyway, I just added them to see what Next's value would be, and it turns out they crash too.
Besides, what would whitespace have to do with a crash?
No, that''s not it. I don''t mean to be rude to those who want to help, but read the post. It stops exactly where I''ve inserted the comment that says PROGRAM STOPS COLD AND DUMPS TO WINDOWS AFTER THIS POINT. All those Event lines output those text quotes to a file, and the very last one I have is "Pointer Ready". NOTHING after that point is executed because nothing comes after that in my log file. The program just dumps. And I just don''t get it.
Hmm... that means the if statement is killing it. Very odd. I think you should show your other functions so we can get a full understanding of how everything works.
I''m currently programming something that dies continuously in the destructor, so I understand how you''re feeling. Dynamic memory is a bitch.
You aren''t assigning NULL to all your deallocated memory pointers. Essentially the program thinks that your memory is still there, and still try''s to access it.