mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
enable memory debugging the same way the curl command line tool already does
This commit is contained in:
parent
b5f85ba77d
commit
4ab0d74250
@ -3,6 +3,7 @@
|
|||||||
#ifdef CURLDEBUG
|
#ifdef CURLDEBUG
|
||||||
/* provide a proto for this debug function */
|
/* provide a proto for this debug function */
|
||||||
extern void curl_memdebug(const char *);
|
extern void curl_memdebug(const char *);
|
||||||
|
extern void curl_memlimit(int);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* test is provided in the test code file */
|
/* test is provided in the test code file */
|
||||||
@ -13,6 +14,21 @@ char *arg2=NULL;
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *URL;
|
char *URL;
|
||||||
|
|
||||||
|
#ifdef CURLDEBUG
|
||||||
|
/* this sends all memory debug messages to a logfile named memdump */
|
||||||
|
char *env = curl_getenv("CURL_MEMDEBUG");
|
||||||
|
if(env) {
|
||||||
|
curl_free(env);
|
||||||
|
curl_memdebug("memdump");
|
||||||
|
}
|
||||||
|
/* this enables the fail-on-alloc-number-N functionality */
|
||||||
|
env = curl_getenv("CURL_MEMLIMIT");
|
||||||
|
if(env) {
|
||||||
|
curl_memlimit(atoi(env));
|
||||||
|
curl_free(env);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if(argc< 2 ) {
|
if(argc< 2 ) {
|
||||||
fprintf(stderr, "Pass URL as argument please\n");
|
fprintf(stderr, "Pass URL as argument please\n");
|
||||||
return 1;
|
return 1;
|
||||||
@ -24,8 +40,5 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
fprintf(stderr, "URL: %s\n", URL);
|
fprintf(stderr, "URL: %s\n", URL);
|
||||||
|
|
||||||
#ifdef CURLDEBUG
|
|
||||||
curl_memdebug("memdump");
|
|
||||||
#endif
|
|
||||||
return test(URL);
|
return test(URL);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <curl.h>
|
#include <curl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
#ifdef HAVE_SYS_SOCKET_H
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user