Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C++ Libraries / May 2004

Tip: Looking for answers? Try searching our database.

Problems with delete []

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mayank Garg - 27 Apr 2004 07:47 GMT
Hi,
I have a structure in a static library, in that I have a byte pointer.
When I delete the byte pointer using delete [] outside the library, it gives me an access violation error.

Please tell me the solution?
LarryWest42 - 13 May 2004 21:41 GMT
Hard to say without specifics, but it the following is a possibility that I've seen: check the alignment/packing of the structure (equivalently, validate that the pointer value you delete[] is the same one you new[]ed.

Since you say static library, I'm assume that the problem of getting different new/malloc/free/delete implementations and different heaps is not a possibility.  Multithreading problems wouldn't normally show up this way since the memory would still be accessible... ah, unless the access violation is internal to delete/free.

Try testing ::IsBadReadPointer() before you call delete[] ... or even easier, step into this the debugger and see what address is actually being passed to delete[].   And if you get weird results, remember the debugger can get fooled sometimes, so look at the assembly and check what's actually being pushed onto the stack for the call to delete[]

Good luck

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.