From: Crispin F. <val...@fl...> - 2003-05-21 16:19:53
|
Hi, When using C++ and new[] with a class that has a destructor, it seems as though the return address from the new[] is 4 bytes into the block allocated. This causes the region of memory to be marked as 'possibly lost'. It seems as though the 4 bytes is used to store the number of items allocated, e.g. in the following program it will contain 1000. #include <stdlib.h> #include <stdio.h> class inner { public: inner() : ptr(0) {} ~inner() { if ( ptr ) delete ptr; } int * ptr; }; inner * info; int main( int argc, char ** argv ) { info = new inner[1000]; exit(0); } This can be fixed by allowing pointers 4 bytes into a block created using new[] and marking them as not lost. The attached patch works for me [TM] (although I am not sure about the assumption that the offset is always 4 bytes) Cheers Crispin |