5 ms·
#define free(x) Most tests still pass, but once the program's been running for a while you'll get a nice memory leak. Fails if your mortal enemy runs leak chec
by bdonlan 15y ago
#define free(x)
Most tests still pass, but once the program's been running for a while you'll get a nice memory leak. Fails if your mortal enemy runs leak checks as part of their standard test suite or other QA, or has a high enough allocation rate to quickly turn up such issues.
- Someone 15y agoImprovement: include some static counter, and only skip the free after a few million (billion?) calls. If possible, also make the thing random, and limit skipping free to a limited range of block sizes. The latter provides a nice false trail for investigators (hm, it is leaking only struct foo...) Problem of course is to find a nice size range for the program at hand.