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