Loading src/tool_main.c +36 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,38 @@ static void main_checkfds(void) #endif } #ifdef CURLDEBUG void memory_tracking_init(void) { char *env; /* if CURL_MEMDEBUG is set, this starts memory tracking message logging */ env = curlx_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_memdebug(fname); /* this weird stuff here is to make curl_free() get called before curl_memdebug() as otherwise memory tracking will log a free() without an alloc! */ } /* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */ env = curlx_getenv("CURL_MEMLIMIT"); if(env) { char *endptr; long num = strtol(env, &endptr, 10); if((endptr != env) && (endptr == env + strlen(env)) && (num > 0)) curl_memlimit(num); curl_free(env); } } #else # define memory_tracking_init() Curl_nop_stmt #endif /* ** curl tool main function. */ Loading @@ -99,6 +131,10 @@ int main(int argc, char *argv[]) (void)signal(SIGPIPE, SIG_IGN); #endif /* Initialize memory tracking */ memory_tracking_init(); /* Start our curl operation */ res = operate(&config, argc, argv); #ifdef __SYMBIAN32__ Loading src/tool_operate.c +1 −4 Original line number Diff line number Diff line Loading @@ -214,12 +214,9 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) heads.stream = stdout; heads.config = config; memory_tracking_init(); /* ** Initialize curl library - do not call any libcurl functions before ** this point. Note that the memory_tracking_init() magic above is an ** exception, but then that's not part of the official public API. ** this point. */ if(main_init() != CURLE_OK) { helpf(config->errors, "error initializing curl library\n"); Loading src/tool_operhlp.c +1 −31 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -219,33 +219,3 @@ void main_free(void) metalink_cleanup(); } #ifdef CURLDEBUG void memory_tracking_init(void) { char *env; /* if CURL_MEMDEBUG is set, this starts memory tracking message logging */ env = curlx_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_memdebug(fname); /* this weird stuff here is to make curl_free() get called before curl_memdebug() as otherwise memory tracking will log a free() without an alloc! */ } /* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */ env = curlx_getenv("CURL_MEMLIMIT"); if(env) { char *endptr; long num = strtol(env, &endptr, 10); if((endptr != env) && (endptr == env + strlen(env)) && (num > 0)) curl_memlimit(num); curl_free(env); } } #endif src/tool_operhlp.h +1 −7 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -41,11 +41,5 @@ CURLcode main_init(void); void main_free(void); #ifdef CURLDEBUG void memory_tracking_init(void); #else # define memory_tracking_init() Curl_nop_stmt #endif #endif /* HEADER_CURL_TOOL_OPERHLP_H */ Loading
src/tool_main.c +36 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,38 @@ static void main_checkfds(void) #endif } #ifdef CURLDEBUG void memory_tracking_init(void) { char *env; /* if CURL_MEMDEBUG is set, this starts memory tracking message logging */ env = curlx_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_memdebug(fname); /* this weird stuff here is to make curl_free() get called before curl_memdebug() as otherwise memory tracking will log a free() without an alloc! */ } /* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */ env = curlx_getenv("CURL_MEMLIMIT"); if(env) { char *endptr; long num = strtol(env, &endptr, 10); if((endptr != env) && (endptr == env + strlen(env)) && (num > 0)) curl_memlimit(num); curl_free(env); } } #else # define memory_tracking_init() Curl_nop_stmt #endif /* ** curl tool main function. */ Loading @@ -99,6 +131,10 @@ int main(int argc, char *argv[]) (void)signal(SIGPIPE, SIG_IGN); #endif /* Initialize memory tracking */ memory_tracking_init(); /* Start our curl operation */ res = operate(&config, argc, argv); #ifdef __SYMBIAN32__ Loading
src/tool_operate.c +1 −4 Original line number Diff line number Diff line Loading @@ -214,12 +214,9 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) heads.stream = stdout; heads.config = config; memory_tracking_init(); /* ** Initialize curl library - do not call any libcurl functions before ** this point. Note that the memory_tracking_init() magic above is an ** exception, but then that's not part of the official public API. ** this point. */ if(main_init() != CURLE_OK) { helpf(config->errors, "error initializing curl library\n"); Loading
src/tool_operhlp.c +1 −31 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -219,33 +219,3 @@ void main_free(void) metalink_cleanup(); } #ifdef CURLDEBUG void memory_tracking_init(void) { char *env; /* if CURL_MEMDEBUG is set, this starts memory tracking message logging */ env = curlx_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_memdebug(fname); /* this weird stuff here is to make curl_free() get called before curl_memdebug() as otherwise memory tracking will log a free() without an alloc! */ } /* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */ env = curlx_getenv("CURL_MEMLIMIT"); if(env) { char *endptr; long num = strtol(env, &endptr, 10); if((endptr != env) && (endptr == env + strlen(env)) && (num > 0)) curl_memlimit(num); curl_free(env); } } #endif
src/tool_operhlp.h +1 −7 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -41,11 +41,5 @@ CURLcode main_init(void); void main_free(void); #ifdef CURLDEBUG void memory_tracking_init(void); #else # define memory_tracking_init() Curl_nop_stmt #endif #endif /* HEADER_CURL_TOOL_OPERHLP_H */