Short story . . . I am trying to override new and delete operators. Seem to be okay on new but on delete I have a problem with this bit of code
cCellList::~cCellList()
{
STPINT loop;
for (loop = 0; loop < count; loop++)
{
delete cells[loop];
}
free(cells);
}
The delete here is not going to my overridden delete operator, so things are not working out. The stack trace says
ExeName.exe!Cell::'scalar deleting destructor'()
ExeName.exe!cCellList::~cCellList()
ExeName.exe!Cell::'scalar deleting destructor'()
The line of code being executed is
delete cells
where cells
is of type cCellList *
.
Long story. I have been working on this executable for nearly 20 years, part time, and it has about 14 MB of source code. All unmanaged C++, currently using VS2010. I started out with a compiler named "Think C with Object-oriented extensions". Probably many of you are too young to remember those days.
Someplace in there is a memory management problem which causes strange things to happen sometimes. I have long since passed the point where third-party solutions like Purify can be used on this program. They just bomb when I try to instrument the code. So I have written my own malloc/free and I am hooking these up to keep better track of what is happening to the memory. So far, I am allocating all the memory with my own system, but in this case it is going to the normal "free" instead of mine, with predictable results.