Heap Corruption??!! Help!!!

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 25
Reputation: kalodakilla is an unknown quantity at this point 
Solved Threads: 0
kalodakilla kalodakilla is offline Offline
Light Poster

Heap Corruption??!! Help!!!

 
0
  #1
Aug 26th, 2008
Hello, i'm doing my home work, it's about managing a library, i created 4 trees as required in my assignment.

The problem arises with RemoveCategory function. I just don't know why but each time i try to remove books in order like this (the names of the books are in "File.txt")

_ Remove Tobie Lolness
_ Remove 1 ve
_ Remove No family
--> Problem arises here, saying that there is a heap corruption. I tried debugging, and when the program get to the line delete [] p->pCategory , it says "heap corruption".

I'm new to this, i don't understand what it's trying to say and how to solve this crazy problem, because when the order is different, the program still runs smoothly ~X(

Help me please ^^ My code is attatched below
Last edited by kalodakilla; Aug 26th, 2008 at 8:47 am.
Attached Files
File Type: zip Assignment 6.zip (15.2 KB, 4 views)
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 206
Reputation: grumpier has a spectacular aura about grumpier has a spectacular aura about 
Solved Threads: 31
grumpier grumpier is offline Offline
Posting Whiz in Training

Re: Heap Corruption??!! Help!!!

 
0
  #2
Aug 26th, 2008
That code is too big for anyone to bother looking at. Try eliminating code to produce a small but complete code sample that exhibits your problem. If you get lucky, you will find/fix the problem in the process of producing that small code sample. If not, people will be more willing and able to help.

Odds are, the cause is an invalid operation on a pointer in code executed before the line where the "heap corruption" is reported. Invalid operations with a pointer include dereferencing a pointer that doesn't actually point at anything valid (eg a NULL, or an uninitialised pointer) or falling off the end of an array (eg accessing element 10 in a 5-element array).
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 25
Reputation: kalodakilla is an unknown quantity at this point 
Solved Threads: 0
kalodakilla kalodakilla is offline Offline
Light Poster

Re: Heap Corruption??!! Help!!!

 
0
  #3
Aug 26th, 2008
Thanks for you reply, i have tried my best to delete other functions, i just kept the add and remove function.

Please just look at the remove functions, especially the RemoveCategory function, all of the problems just arise there. Can you just remove the books in the order i mention and do you meet the same error like i do , plz

I consider checking if i delete any NULL pointer, but still, i'm not deleting any NULL things, i just don't know why the dynamic array is right there and i can't delete it ~X(
Attached Files
File Type: zip Assignment 6.zip (12.4 KB, 3 views)
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 25
Reputation: kalodakilla is an unknown quantity at this point 
Solved Threads: 0
kalodakilla kalodakilla is offline Offline
Light Poster

Re: Heap Corruption??!! Help!!!

 
0
  #4
Aug 26th, 2008
Oh, silly me, i have found my problems, the heap corruption occurs because i have not allocated new memory but use the same memory. Thanks very much for your regards
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC