First draft for discussion. Not, um, well tested yet.
ANSI C++ mandates separate vector versions of new and delete that do the same thing as the non-vector versions, but which can be replaced by user apps (see http://www.csci.csusb.edu/dick/c++std/cd2/lib-support.html#lib.new.delete ) So far, so good; wine does that in msvcrt.
However, once in a while, a programmer will call delete when he should have called delete[], and a bunch of destructors won't get called. To detect this programming error, let's split the vector new and delete functions off from their scalar twins, and add values for the heap function flags so we can inform valgrind what kind of blocks are being wrangled.
This means picking two flag bits that Microsoft doesn't use; there seem to be enough to go around.
Requires the corresponding patch to valgrind ttps://bugs.kde.org/show_bug.cgi?id=218741
Thanks to Steve Vandebogart for his help on this; he wrote a bunch of it.
Dan Kegel dank@kegel.com writes:
However, once in a while, a programmer will call delete when he should have called delete[], and a bunch of destructors won't get called. To detect this programming error, let's split the vector new and delete functions off from their scalar twins, and add values for the heap function flags so we can inform valgrind what kind of blocks are being wrangled.
This means picking two flag bits that Microsoft doesn't use; there seem to be enough to go around.
If you mean inventing new flags to HeapAlloc and friends, then no, you can't do that.