Dmalloc Logo
Home

Documentation
Downloads
Forums
Releases

Search this site:

Donations:
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.11 Using the library with Cygwin environment.
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.11 Using the library with Cygwin environment.

The Cygwin environment is a Linux-like environment for Windows. It provides Linux look and feel as well as a programming environment. See URL http://www.cygwin.com/ for more details.

Cygwin uses the GetEnvironmentVariableA function to read in environmental variables instead of getenv. This functions are used to get the value of the `DMALLOC_OPTIONS' variable which sets the debugging options. See section Environment Variable Name and Features.

As of right now, dmalloc is not detecting the GetEnvironmentVariableA function correctly so you may need to tune the `conf.h' file to get it to work. See the sections on HAVE_GETENVIRONMENTVARIABLEA and GETENV_SAVE settings. Feedback is welcome here.

If you still have problems reading in the environmental variables, you can work around this issue. You can add some code into the main function in your program to initialize the dmalloc flags yourself. Here is a code sample:

 
main(int argc, char **argv)
{
#ifdef DMALLOC
  /*
   * Get environ variable DMALLOC_OPTIONS and pass the settings string
   * on to dmalloc_debug_setup to setup the dmalloc debugging flags.
   */
  dmalloc_debug_setup(getenv("DMALLOC_OPTIONS"));
#endif

  /* rest of code in main starts here */
  …
}

The #ifdef is just a good idea. I means that when debugging with dmalloc you need to compile your code with -DDMALLOC. When you are done debugging you can remove the flag and the call to dmalloc_debug_setup will be removed.

Please let me know if there is a better way to do this.


[ < ] [ > ]   [ << ] [ 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.