Dmalloc Logo


Search this site:

If dmalloc has saved you or your company time or money, please use your credit-card or PayPal account to donate to the cause.

Dmalloc Tutorial: 3.6 How to Disable the library
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.6 How to Disable the library

When you are finished with the development and debugging sessions, you may want to disable the dmalloc library and put in its place either the system's memory-allocation routines, gnu-malloc, or maybe your own. Attempts have been made to make this a reasonably painless process. The ease of the extraction depends heavily on how many of the library's features your made use of during your coding.

Reasonable suggestions are welcome as to how to improve this process while maintaining the effectiveness of the debugging.

  • If you want to totally disable the dmalloc library then you will need to recompile all the C files that include `dmalloc.h' while defining DMALLOC_DISABLE. This will cause the dmalloc macros to not be applied. See section Macros Providing File and Line Information.
    cc -g -DDMALLOC_DISABLE main.c

    An alternative is to surround the dmalloc.h inclusion or any direct dmalloc references with an #ifdef dmalloc and then just remove the -Ddmalloc.

    #ifdef dmalloc
    #include "dmalloc.h"
    #ifdef dmalloc
      return 0;
    // to get dmalloc information
    $ cc -Ddmalloc main.c
    // without dmalloc information
    $ cc main.c
  • If you compiled any of your source modules with DMALLOC_FUNC_CHECK defined then you must first recompile all those modules without the flag enabled.

    If you have disabled dmalloc with the DMALLOC_DISABLED flag or never included `dmalloc.h' in any of your C files, then you will not need to recompile your sources when you need to disable the library.

    If you get unresolved references like _dmalloc_malloc or _dmalloc_bcopy then something was not disabled as it should have been.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by Gray Watson on May, 16 2007 using texi2html 1.76.

This work is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.
This page should be W3C Valid XHTML and should work with most browsers.