mirror of
https://github.com/curl/curl.git
synced 2026-07-16 06:27:17 +03:00
libtest/first: stop defining MEMDEBUG_NODEFINES
It causes problems in unity builds, in particular when this file is used for unit tests. Bonus: switch to plain getenv() instead of curl_getenv() to avoid extra malloc/free rounds. Closes #16978
This commit is contained in:
parent
f3527ed443
commit
3454844f36
1 changed files with 4 additions and 18 deletions
|
|
@ -28,13 +28,8 @@
|
|||
# include <locale.h> /* for setlocale() */
|
||||
#endif
|
||||
|
||||
#ifdef CURLDEBUG
|
||||
# define MEMDEBUG_NODEFINES
|
||||
# include "memdebug.h"
|
||||
#endif
|
||||
|
||||
#include "memdebug.h"
|
||||
#include "timediff.h"
|
||||
|
||||
#include "tool_binmode.h"
|
||||
|
||||
int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
|
||||
|
|
@ -88,27 +83,18 @@ static void memory_tracking_init(void)
|
|||
{
|
||||
char *env;
|
||||
/* if CURL_MEMDEBUG is set, this starts memory tracking message logging */
|
||||
env = curl_getenv("CURL_MEMDEBUG");
|
||||
env = getenv("CURL_MEMDEBUG");
|
||||
if(env) {
|
||||
/* use the value as file name */
|
||||
char fname[CURL_MT_LOGFNAME_BUFSIZE];
|
||||
if(strlen(env) >= CURL_MT_LOGFNAME_BUFSIZE)
|
||||
env[CURL_MT_LOGFNAME_BUFSIZE-1] = '\0';
|
||||
strcpy(fname, env);
|
||||
curl_free(env);
|
||||
curl_dbg_memdebug(fname);
|
||||
/* this weird stuff here is to make curl_free() get called before
|
||||
curl_dbg_memdebug() as otherwise memory tracking will log a free()
|
||||
without an alloc! */
|
||||
curl_dbg_memdebug(env);
|
||||
}
|
||||
/* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */
|
||||
env = curl_getenv("CURL_MEMLIMIT");
|
||||
env = getenv("CURL_MEMLIMIT");
|
||||
if(env) {
|
||||
char *endptr;
|
||||
long num = strtol(env, &endptr, 10);
|
||||
if((endptr != env) && (endptr == env + strlen(env)) && (num > 0))
|
||||
curl_dbg_memlimit(num);
|
||||
curl_free(env);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue