From: Greg C. <chi...@co...> - 2006-06-15 12:20:01
|
On 2006-6-15 12:02 UTC, Dan Osborne wrote: > Thanks Richard, mpatrol looks well worth a try. > > I'm giving it a go at the moment but having trouble with this bit of mpatrol > documentation ... > > but you should note that if your program does not directly call any of the > functions in the mpatrol library then it will not be linked in and you will > not see a log file being generated when you run it. You can force the > linking of the mpatrol library by causing malloc() to be undefined on the > link line, usually through the use of the `-u' linker option. Here's what I've been using for years in production code: #include <cstdlib> // std::free() [first line of main(), WinMain(), or what have you:] // This line forces mpatrol to link when it otherwise might not. // It has no other effect according to C99 7.20.3.2/2, second // sentence. std::free(0); No need for a '-u' option that may be dependent on whose linker or which platform you're using; just standard C++. (The C version would be trivially different.) Similarly, I prefer free() to malloc() because I can call it in a way guaranteed to have no side effect. |