diff --git a/lib/memdebug.c b/lib/memdebug.c index 2b6c55c3b0895a3f5c5eed69ee4ea4d9d6a7917a..a8cca44cbc4583b451682d9f95960d75d14906a8 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -61,25 +61,29 @@ struct memdebug { */ #define logfile curl_debuglogfile -FILE *curl_debuglogfile; -static bool memlimit; /* enable memory limit */ -static long memsize; /* set number of mallocs allowed */ +FILE *curl_debuglogfile = NULL; +static bool memlimit = FALSE; /* enable memory limit */ +static long memsize = 0; /* set number of mallocs allowed */ /* this sets the log file name */ void curl_memdebug(const char *logname) { - if(logname) - logfile = fopen(logname, "w"); - else - logfile = stderr; + if (!logfile) { + if(logname) + logfile = fopen(logname, "w"); + else + logfile = stderr; + } } /* This function sets the number of malloc() calls that should return successfully! */ void curl_memlimit(long limit) { - memlimit = TRUE; - memsize = limit; + if (!memlimit) { + memlimit = TRUE; + memsize = limit; + } } /* returns TRUE if this isn't allowed! */