From d49d05bce603313d71f1a2b9904c74ca7b368703 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 9 Oct 2000 11:11:43 +0000 Subject: added for memory leak debugging etc --- lib/memdebug.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lib/memdebug.h (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h new file mode 100644 index 000000000..a0d670088 --- /dev/null +++ b/lib/memdebug.h @@ -0,0 +1,13 @@ +#ifdef MALLOCDEBUG +void *curl_domalloc(size_t size, int line, char *source); +void *curl_dorealloc(void *ptr, size_t size, int line, char *source); +void curl_dofree(void *ptr, int line, char *source); +char *curl_dostrdup(char *str, int line, char *source); +void curl_memdebug(char *logname); + +/* Set this symbol on the command-line, recompile all lib-sources */ +#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__) +#define malloc(size) curl_domalloc(size, __LINE__, __FILE__) +#define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__) +#define free(ptr) curl_dofree(ptr, __LINE__, __FILE__) +#endif -- cgit v1.2.1 From bf43b49a200dace98a5245e782e0831313461b31 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 14 Dec 2000 15:56:59 +0000 Subject: added socket() / sclose() checks to the memdebug system --- lib/memdebug.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index a0d670088..21330a0b2 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -1,13 +1,26 @@ #ifdef MALLOCDEBUG +/* memory functions */ void *curl_domalloc(size_t size, int line, char *source); void *curl_dorealloc(void *ptr, size_t size, int line, char *source); void curl_dofree(void *ptr, int line, char *source); char *curl_dostrdup(char *str, int line, char *source); void curl_memdebug(char *logname); +/* file descriptor manipulators */ +int curl_socket(int domain, int type, int protocol, int, char *); +int curl_sclose(int sockfd, int, char *); + /* Set this symbol on the command-line, recompile all lib-sources */ #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__) #define malloc(size) curl_domalloc(size, __LINE__, __FILE__) #define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__) #define free(ptr) curl_dofree(ptr, __LINE__, __FILE__) + +#define socket(domain,type,protocol)\ + curl_socket(domain,type,protocol,__LINE__,__FILE__) + +/* sclose is probably already defined, redefine it! */ +#undef sclose +#define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__) + #endif -- cgit v1.2.1 From 184ad46a27dc65a82faa2cda76fe91bcca3404cf Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 18 Dec 2000 16:13:37 +0000 Subject: fixed accept() for memory debugging --- lib/memdebug.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 21330a0b2..86271b5b2 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -9,6 +9,8 @@ void curl_memdebug(char *logname); /* file descriptor manipulators */ int curl_socket(int domain, int type, int protocol, int, char *); int curl_sclose(int sockfd, int, char *); +int curl_accept(int s, struct sockaddr *addr, int *addrlen, + int line, char *source); /* Set this symbol on the command-line, recompile all lib-sources */ #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__) @@ -18,6 +20,8 @@ int curl_sclose(int sockfd, int, char *); #define socket(domain,type,protocol)\ curl_socket(domain,type,protocol,__LINE__,__FILE__) +#define accept(sock,addr,len)\ + curl_accept(sock,addr,len,__LINE__,__FILE__) /* sclose is probably already defined, redefine it! */ #undef sclose -- cgit v1.2.1 From 5594741acbb6fb88ad840c6fa7ca328ff032497c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 19 Dec 2000 13:23:54 +0000 Subject: Added fopen() and fclose() leak tracking --- lib/memdebug.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 86271b5b2..58657c35d 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -1,4 +1,8 @@ #ifdef MALLOCDEBUG + +#include +#include + /* memory functions */ void *curl_domalloc(size_t size, int line, char *source); void *curl_dorealloc(void *ptr, size_t size, int line, char *source); @@ -12,6 +16,10 @@ int curl_sclose(int sockfd, int, char *); int curl_accept(int s, struct sockaddr *addr, int *addrlen, int line, char *source); +/* FILE functions */ +FILE *curl_fopen(char *file, char *mode, int line, char *source); +int curl_fclose(FILE *file, int line, char *source); + /* Set this symbol on the command-line, recompile all lib-sources */ #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__) #define malloc(size) curl_domalloc(size, __LINE__, __FILE__) @@ -27,4 +35,8 @@ int curl_accept(int s, struct sockaddr *addr, int *addrlen, #undef sclose #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__) +#undef fopen +#define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__) +#define fclose(file) curl_fclose(file,__LINE__,__FILE__) + #endif -- cgit v1.2.1 From b6c5da337aa6648bf9f39cd15f97123e64b4a91f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 2 Mar 2001 07:41:40 +0000 Subject: strdup() takes a const char * now --- lib/memdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 58657c35d..fc9a3222a 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -7,7 +7,7 @@ void *curl_domalloc(size_t size, int line, char *source); void *curl_dorealloc(void *ptr, size_t size, int line, char *source); void curl_dofree(void *ptr, int line, char *source); -char *curl_dostrdup(char *str, int line, char *source); +char *curl_dostrdup(const char *str, int line, char *source); void curl_memdebug(char *logname); /* file descriptor manipulators */ -- cgit v1.2.1 From 3e7ebcd0513d4f55b8fc552a0791c60fe5af0c34 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 9 Mar 2001 15:13:34 +0000 Subject: uses socklen_t now --- lib/memdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index fc9a3222a..2ee523327 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -13,7 +13,7 @@ void curl_memdebug(char *logname); /* file descriptor manipulators */ int curl_socket(int domain, int type, int protocol, int, char *); int curl_sclose(int sockfd, int, char *); -int curl_accept(int s, struct sockaddr *addr, int *addrlen, +int curl_accept(int s, struct sockaddr *addr, socklen_t *addrlen, int line, char *source); /* FILE functions */ -- cgit v1.2.1 From d30c478378ce5e135379210c970d26db5f73078e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 6 Aug 2001 12:23:31 +0000 Subject: Nico's VMS adjustment --- lib/memdebug.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 2ee523327..03f154a1e 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -2,6 +2,9 @@ #include #include +#ifdef HAVE_MEMORY_H +#include +#endif /* memory functions */ void *curl_domalloc(size_t size, int line, char *source); -- cgit v1.2.1 From 5afc69487981557710037f6bfd858fc81fd4ffee Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 14 Aug 2001 08:31:27 +0000 Subject: const-ified lots of function arguments --- lib/memdebug.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 03f154a1e..419b8b943 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -7,21 +7,22 @@ #endif /* memory functions */ -void *curl_domalloc(size_t size, int line, char *source); -void *curl_dorealloc(void *ptr, size_t size, int line, char *source); -void curl_dofree(void *ptr, int line, char *source); -char *curl_dostrdup(const char *str, int line, char *source); +void *curl_domalloc(size_t size, int line, const char *source); +void *curl_dorealloc(void *ptr, size_t size, int line, const char *source); +void curl_dofree(void *ptr, int line, const char *source); +char *curl_dostrdup(const char *str, int line, const char *source); void curl_memdebug(char *logname); /* file descriptor manipulators */ -int curl_socket(int domain, int type, int protocol, int, char *); -int curl_sclose(int sockfd, int, char *); +int curl_socket(int domain, int type, int protocol, int, const char *); +int curl_sclose(int sockfd, int, const char *source); int curl_accept(int s, struct sockaddr *addr, socklen_t *addrlen, - int line, char *source); + int line, const char *source); /* FILE functions */ -FILE *curl_fopen(char *file, char *mode, int line, char *source); -int curl_fclose(FILE *file, int line, char *source); +FILE *curl_fopen(const char *file, const char *mode, int line, + const char *source); +int curl_fclose(FILE *file, int line, const char *source); /* Set this symbol on the command-line, recompile all lib-sources */ #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__) -- cgit v1.2.1 From 1a7e13e166dd0c90cebe2ccd4585c217795ad42c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 14 Aug 2001 09:24:48 +0000 Subject: curl_memdebug takes a const argument now --- lib/memdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 419b8b943..2a6a35ac2 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -11,7 +11,7 @@ void *curl_domalloc(size_t size, int line, const char *source); void *curl_dorealloc(void *ptr, size_t size, int line, const char *source); void curl_dofree(void *ptr, int line, const char *source); char *curl_dostrdup(const char *str, int line, const char *source); -void curl_memdebug(char *logname); +void curl_memdebug(const char *logname); /* file descriptor manipulators */ int curl_socket(int domain, int type, int protocol, int, const char *); -- cgit v1.2.1 From 5d9ae88f58349022ee437fdf4dfc9e3a7f755beb Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 4 Oct 2001 13:25:12 +0000 Subject: getaddrinfo() cleanups --- lib/memdebug.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 2a6a35ac2..ebb240928 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -6,6 +6,8 @@ #include #endif +extern FILE *logfile; + /* memory functions */ void *curl_domalloc(size_t size, int line, const char *source); void *curl_dorealloc(void *ptr, size_t size, int line, const char *source); @@ -35,6 +37,11 @@ int curl_fclose(FILE *file, int line, const char *source); #define accept(sock,addr,len)\ curl_accept(sock,addr,len,__LINE__,__FILE__) +#define getaddrinfo(host,serv,hint,res) \ + curl_getaddrinfo(host,serv,hint,res,__LINE__,__FILE__) +#define freeaddrinfo(data) \ + curl_freeaddrinfo(data,__LINE__,__FILE__) + /* sclose is probably already defined, redefine it! */ #undef sclose #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__) -- cgit v1.2.1 From af6c394785d9ca41ec34ab26a9308b8a4d2a1260 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 17 Dec 2001 23:01:39 +0000 Subject: =?UTF-8?q?G=F6tz=20Babin-Ebell's=20OpenSSL=20ENGINE=20patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/memdebug.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index ebb240928..3c5c090f6 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -1,6 +1,14 @@ #ifdef MALLOCDEBUG +#include "setup.h" + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SYS_SOCKET_H #include +#endif #include #ifdef HAVE_MEMORY_H #include -- cgit v1.2.1 From 974f314f5785156af6983675aeb28313cc8ba2ea Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 19 Mar 2002 07:54:55 +0000 Subject: copyright string (year) update --- lib/memdebug.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 3c5c090f6..99997521b 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -1,4 +1,26 @@ #ifdef MALLOCDEBUG +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2002, Daniel Stenberg, , et al. + * + * In order to be useful for every potential user, curl and libcurl are + * dual-licensed under the MPL and the MIT/X-derivate licenses. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the MPL or the MIT/X-derivate + * licenses. You may pick one of these licenses. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * $Id$ + *****************************************************************************/ #include "setup.h" -- cgit v1.2.1 From ba4e69bebc8f7f32f3bc7faa1e13e7580754075b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 3 Sep 2002 11:52:59 +0000 Subject: updated source code boilerplate/header --- lib/memdebug.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 99997521b..b2399a269 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -1,5 +1,5 @@ #ifdef MALLOCDEBUG -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | @@ -8,19 +8,19 @@ * * Copyright (C) 1998 - 2002, Daniel Stenberg, , et al. * - * In order to be useful for every potential user, curl and libcurl are - * dual-licensed under the MPL and the MIT/X-derivate licenses. - * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the MPL or the MIT/X-derivate - * licenses. You may pick one of these licenses. + * furnished to do so, under the terms of the COPYING file. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * * $Id$ - *****************************************************************************/ + ***************************************************************************/ #include "setup.h" -- cgit v1.2.1 From b8a6913e0965e5f492dfbe2b39b52ab5813bf08d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 28 Oct 2002 19:20:59 +0000 Subject: prevent compiler warnings --- lib/memdebug.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index b2399a269..3fa87ac9e 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -57,6 +57,7 @@ FILE *curl_fopen(const char *file, const char *mode, int line, int curl_fclose(FILE *file, int line, const char *source); /* Set this symbol on the command-line, recompile all lib-sources */ +#undef strdup #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__) #define malloc(size) curl_domalloc(size, __LINE__, __FILE__) #define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__) -- cgit v1.2.1 From f26a338a54e04d0a6907f5d2479d8b0fa9daf297 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 16 Jan 2003 21:08:12 +0000 Subject: copyright year update in the source header --- lib/memdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 3fa87ac9e..addecef8f 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -6,7 +6,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2002, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2003, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From e6bfbe968306090d4c48e02f29b1b54b8351915b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 15 Mar 2003 21:02:20 +0000 Subject: Gisle Vanem's fix to get this working nicely on windows --- lib/memdebug.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index addecef8f..87df8f297 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -28,6 +28,9 @@ #include #endif +#ifdef WIN32 +#include +#endif #ifdef HAVE_SYS_SOCKET_H #include #endif -- cgit v1.2.1 From f7d795a364096b384075b8e918760292ba054f69 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 26 Jun 2003 11:27:38 +0000 Subject: use CURLDEBUG --- lib/memdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 87df8f297..ebb338210 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -1,4 +1,4 @@ -#ifdef MALLOCDEBUG +#ifdef CURLDEBUG /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | -- cgit v1.2.1 From 02c78ecf8134fc9961efd3563970672858d503fd Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 14 Aug 2003 14:19:36 +0000 Subject: allow out-of-memory testing by setting a limit. That number of memory allocation calls will succeed, the following will return NULL! --- lib/memdebug.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index ebb338210..dae8ce151 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -39,6 +39,8 @@ #include #endif +#define logfile curl_debuglogfile + extern FILE *logfile; /* memory functions */ @@ -47,6 +49,7 @@ void *curl_dorealloc(void *ptr, size_t size, int line, const char *source); void curl_dofree(void *ptr, int line, const char *source); char *curl_dostrdup(const char *str, int line, const char *source); void curl_memdebug(const char *logname); +void curl_memlimit(long limit); /* file descriptor manipulators */ int curl_socket(int domain, int type, int protocol, int, const char *); -- cgit v1.2.1 From 749f5387c19449209615b282ac738032f2a890e7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 14 Oct 2003 12:00:45 +0000 Subject: Gisle Vanem's IPv6-on-Windows patch applied! --- lib/memdebug.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index dae8ce151..b28154a81 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -28,9 +28,6 @@ #include #endif -#ifdef WIN32 -#include -#endif #ifdef HAVE_SYS_SOCKET_H #include #endif -- cgit v1.2.1 From 053f6c85efd0bf698f73343989474d672d0563a8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 7 Jan 2004 09:19:33 +0000 Subject: updated year in the copyright string --- lib/memdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index b28154a81..f1454b63b 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -6,7 +6,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2003, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From 4d17d6876e4b2f08380812c4ec113073b0a14639 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 29 Jan 2004 13:56:45 +0000 Subject: Dan Fandrich's cleanup patch to make pedantic compiler options cause less warnings. Minor edits by me. --- lib/memdebug.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index f1454b63b..6c289bd4d 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -49,7 +49,7 @@ void curl_memdebug(const char *logname); void curl_memlimit(long limit); /* file descriptor manipulators */ -int curl_socket(int domain, int type, int protocol, int, const char *); +int curl_socket(int domain, int type, int protocol, int line , const char *); int curl_sclose(int sockfd, int, const char *source); int curl_accept(int s, struct sockaddr *addr, socklen_t *addrlen, int line, const char *source); @@ -59,6 +59,8 @@ FILE *curl_fopen(const char *file, const char *mode, int line, const char *source); int curl_fclose(FILE *file, int line, const char *source); +#ifndef MEMDEBUG_NODEFINES + /* Set this symbol on the command-line, recompile all lib-sources */ #undef strdup #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__) @@ -84,4 +86,6 @@ int curl_fclose(FILE *file, int line, const char *source); #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__) #define fclose(file) curl_fclose(file,__LINE__,__FILE__) +#endif /* MEMDEBUG_NODEFINES */ + #endif -- cgit v1.2.1 From 0412a201a341390f443270211ce02c7c5fa23e20 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 2 Feb 2004 21:34:01 +0000 Subject: undef accept before defining it, since AIX 5.2 has it as a define! --- lib/memdebug.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 6c289bd4d..7b7b713e2 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -70,6 +70,7 @@ int curl_fclose(FILE *file, int line, const char *source); #define socket(domain,type,protocol)\ curl_socket(domain,type,protocol,__LINE__,__FILE__) +#undef accept /* for those with accept as a macro */ #define accept(sock,addr,len)\ curl_accept(sock,addr,len,__LINE__,__FILE__) -- cgit v1.2.1 From 09aa1659427eff5f695ada0f1666d8f1ba1d3934 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 16 Feb 2004 16:24:01 +0000 Subject: support closesocket() for closing sockets as well, as then we can use this code fine on ares! --- lib/memdebug.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 7b7b713e2..48f487d67 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -82,6 +82,9 @@ int curl_fclose(FILE *file, int line, const char *source); /* sclose is probably already defined, redefine it! */ #undef sclose #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__) +/* ares-adjusted define: */ +#undef closesocket +#define closesocket(sockfd) curl_sclose(sockfd,__LINE__,__FILE__) #undef fopen #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__) -- cgit v1.2.1 From f33be3c31320e4c92531be02df52800e56ab872b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 18 Feb 2004 12:18:33 +0000 Subject: Modified curl_accept() to take a 'void *' in the 2nd argument instead of sockaddr *. This has the added benefit that source files that include memdebug.h doesn't have to know about "sockaddr". --- lib/memdebug.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 48f487d67..825526d42 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -1,4 +1,6 @@ #ifdef CURLDEBUG +#ifndef _CURL_MEDEBUG_H +#define _CURL_MEDEBUG_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -22,6 +24,11 @@ * $Id$ ***************************************************************************/ +/* + * CAUTION: this header is designed to work when included by the app-side + * as well as the library. Do not mix with library internals! + */ + #include "setup.h" #ifdef HAVE_SYS_TYPES_H @@ -51,7 +58,7 @@ void curl_memlimit(long limit); /* file descriptor manipulators */ int curl_socket(int domain, int type, int protocol, int line , const char *); int curl_sclose(int sockfd, int, const char *source); -int curl_accept(int s, struct sockaddr *addr, socklen_t *addrlen, +int curl_accept(int s, void *addr, socklen_t *addrlen, int line, const char *source); /* FILE functions */ @@ -92,4 +99,5 @@ int curl_fclose(FILE *file, int line, const char *source); #endif /* MEMDEBUG_NODEFINES */ -#endif +#endif /* _CURL_MEDEBUG_H */ +#endif /* CURLDEBUG */ -- cgit v1.2.1 From de681d3b8fd0cff2428a5d8f926eb9838dc619b0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 18 Feb 2004 12:22:56 +0000 Subject: Made curl_accept() take a 'void *' instead of 'socklen_t *' in the 3rd argument to also not force the casual includer to know about the socklen_t type. --- lib/memdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 825526d42..2bf75e58d 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -58,7 +58,7 @@ void curl_memlimit(long limit); /* file descriptor manipulators */ int curl_socket(int domain, int type, int protocol, int line , const char *); int curl_sclose(int sockfd, int, const char *source); -int curl_accept(int s, void *addr, socklen_t *addrlen, +int curl_accept(int s, void *addr, void *addrlen, int line, const char *source); /* FILE functions */ -- cgit v1.2.1 From 07de0ff0ff2e99ae18c0326c1916e07ca5847028 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 26 Feb 2004 14:52:51 +0000 Subject: Gisle Vanem's added support calloc()-debugging and outputting mode for fopen() as well. --- lib/memdebug.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 2bf75e58d..40ba08033 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -49,6 +49,7 @@ extern FILE *logfile; /* memory functions */ void *curl_domalloc(size_t size, int line, const char *source); +void *curl_docalloc(size_t elements, size_t size, int line, const char *source); void *curl_dorealloc(void *ptr, size_t size, int line, const char *source); void curl_dofree(void *ptr, int line, const char *source); char *curl_dostrdup(const char *str, int line, const char *source); @@ -72,6 +73,7 @@ int curl_fclose(FILE *file, int line, const char *source); #undef strdup #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__) #define malloc(size) curl_domalloc(size, __LINE__, __FILE__) +#define calloc(nbelem,size) curl_docalloc(nbelem, size, __LINE__, __FILE__) #define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__) #define free(ptr) curl_dofree(ptr, __LINE__, __FILE__) -- cgit v1.2.1 From 648e82f05d8bce097f9f81b78d9df40f647f6170 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 26 Apr 2004 07:20:11 +0000 Subject: Major hostip.c cleanup and split into multiple files and easier #ifdef usage. --- lib/memdebug.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 40ba08033..42574cf43 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -84,9 +84,12 @@ int curl_fclose(FILE *file, int line, const char *source); curl_accept(sock,addr,len,__LINE__,__FILE__) #define getaddrinfo(host,serv,hint,res) \ - curl_getaddrinfo(host,serv,hint,res,__LINE__,__FILE__) + curl_dogetaddrinfo(host,serv,hint,res,__LINE__,__FILE__) +#define getnameinfo(sa,salen,host,hostlen,serv,servlen,flags) \ + curl_dogetnameinfo(sa,salen,host,hostlen,serv,servlen,flags, __LINE__, \ + __FILE__) #define freeaddrinfo(data) \ - curl_freeaddrinfo(data,__LINE__,__FILE__) + curl_dofreeaddrinfo(data,__LINE__,__FILE__) /* sclose is probably already defined, redefine it! */ #undef sclose -- cgit v1.2.1 From 377e43fbb9ff48fc114c9c6ecc1b04796e01b0fb Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Tue, 9 Nov 2004 14:00:56 +0000 Subject: Changes for removing libcurl.def file on Win32. Added "CURL_EXTERN" to memdebug.h functions. Cleaned up Makefile.vc6. --- lib/memdebug.h | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 42574cf43..b8ac6a870 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -2,10 +2,10 @@ #ifndef _CURL_MEDEBUG_H #define _CURL_MEDEBUG_H /*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. @@ -13,7 +13,7 @@ * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://curl.haxx.se/docs/copyright.html. - * + * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. @@ -31,6 +31,8 @@ #include "setup.h" +#include + #ifdef HAVE_SYS_TYPES_H #include #endif @@ -48,24 +50,24 @@ extern FILE *logfile; /* memory functions */ -void *curl_domalloc(size_t size, int line, const char *source); -void *curl_docalloc(size_t elements, size_t size, int line, const char *source); -void *curl_dorealloc(void *ptr, size_t size, int line, const char *source); -void curl_dofree(void *ptr, int line, const char *source); -char *curl_dostrdup(const char *str, int line, const char *source); -void curl_memdebug(const char *logname); -void curl_memlimit(long limit); +CURL_EXTERN void *curl_domalloc(size_t size, int line, const char *source); +CURL_EXTERN void *curl_docalloc(size_t elements, size_t size, int line, const char *source); +CURL_EXTERN void *curl_dorealloc(void *ptr, size_t size, int line, const char *source); +CURL_EXTERN void curl_dofree(void *ptr, int line, const char *source); +CURL_EXTERN char *curl_dostrdup(const char *str, int line, const char *source); +CURL_EXTERN void curl_memdebug(const char *logname); +CURL_EXTERN void curl_memlimit(long limit); /* file descriptor manipulators */ -int curl_socket(int domain, int type, int protocol, int line , const char *); -int curl_sclose(int sockfd, int, const char *source); -int curl_accept(int s, void *addr, void *addrlen, - int line, const char *source); +CURL_EXTERN int curl_socket(int domain, int type, int protocol, int line , const char *); +CURL_EXTERN int curl_sclose(int sockfd, int, const char *source); +CURL_EXTERN int curl_accept(int s, void *addr, void *addrlen, + int line, const char *source); /* FILE functions */ -FILE *curl_fopen(const char *file, const char *mode, int line, - const char *source); -int curl_fclose(FILE *file, int line, const char *source); +CURL_EXTERN FILE *curl_fopen(const char *file, const char *mode, int line, + const char *source); +CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #ifndef MEMDEBUG_NODEFINES -- cgit v1.2.1 From ab4086bc244bf3267976e9f0193e5ed4430190d8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 31 Mar 2005 07:02:02 +0000 Subject: Updated the copyright year since changes have been this year. --- lib/memdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index b8ac6a870..8ce11ed88 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -8,7 +8,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2005, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From 883479f01e3792d2ef8428839fbd84a1fe7c1520 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 30 Jun 2005 13:28:58 +0000 Subject: enable memory debugging on tru64 with ipv6 support by doing a little different defining, since the system headers themselves redefine getaddrinfo --- lib/memdebug.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 8ce11ed88..23b420e2e 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -85,8 +85,16 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #define accept(sock,addr,len)\ curl_accept(sock,addr,len,__LINE__,__FILE__) +#if defined(getaddrinfo) && defined(__osf__) +/* OSF/1 and Tru64 have getaddrinfo as a define already, so we cannot define + our macro as for other platforms. Instead, we redefine the new name they + define getaddrinfo to become! */ +#define ogetaddrinfo(host,serv,hint,res) \ + curl_dogetaddrinfo(host,serv,hint,res,__LINE__,__FILE__) +#else #define getaddrinfo(host,serv,hint,res) \ curl_dogetaddrinfo(host,serv,hint,res,__LINE__,__FILE__) +#endif #define getnameinfo(sa,salen,host,hostlen,serv,servlen,flags) \ curl_dogetnameinfo(sa,salen,host,hostlen,serv,servlen,flags, __LINE__, \ __FILE__) -- cgit v1.2.1 From 9ace30352874529fa85f25da80b1cfe4e2bfa4ae Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 13 Nov 2005 23:53:14 +0000 Subject: Yang Tse fixed compiler warnings --- lib/memdebug.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 23b420e2e..4d965fb1f 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -92,12 +92,15 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #define ogetaddrinfo(host,serv,hint,res) \ curl_dogetaddrinfo(host,serv,hint,res,__LINE__,__FILE__) #else +#undef getaddrinfo #define getaddrinfo(host,serv,hint,res) \ curl_dogetaddrinfo(host,serv,hint,res,__LINE__,__FILE__) #endif +#undef getnameinfo #define getnameinfo(sa,salen,host,hostlen,serv,servlen,flags) \ curl_dogetnameinfo(sa,salen,host,hostlen,serv,servlen,flags, __LINE__, \ __FILE__) +#undef freeaddrinfo #define freeaddrinfo(data) \ curl_dofreeaddrinfo(data,__LINE__,__FILE__) -- cgit v1.2.1 From 55138753c63cb7a6d1191028df25b689b73baefa Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 4 Jul 2006 02:27:11 +0000 Subject: Test HAVE_GETNAMEINFO definition before using GETNAMEINFO_XXX definitions. --- lib/memdebug.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 4d965fb1f..d64defed6 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -96,10 +96,14 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #define getaddrinfo(host,serv,hint,res) \ curl_dogetaddrinfo(host,serv,hint,res,__LINE__,__FILE__) #endif + +#ifdef HAVE_GETNAMEINFO #undef getnameinfo #define getnameinfo(sa,salen,host,hostlen,serv,servlen,flags) \ curl_dogetnameinfo(sa,salen,host,hostlen,serv,servlen,flags, __LINE__, \ __FILE__) +#endif + #undef freeaddrinfo #define freeaddrinfo(data) \ curl_dofreeaddrinfo(data,__LINE__,__FILE__) -- cgit v1.2.1 From 772a985dc3318214443ddd2ad6541d520f089368 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 27 Oct 2006 03:47:57 +0000 Subject: Update copyright year, since the file has been modified --- lib/memdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index d64defed6..a4ce7e59a 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -8,7 +8,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2005, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From aed0cc6f2a9a7fdaae08ad6700687f7200b4ebaa Mon Sep 17 00:00:00 2001 From: James Housley Date: Thu, 28 Jun 2007 11:11:29 +0000 Subject: Using fdopen() is a more correct way to implement the CURLOPT_NEW_FILE_PREMS file.c, but the debug interface was missing. This adds the routines needed to make the memory debuging work for fdopen(). --- lib/memdebug.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index a4ce7e59a..4e50ad1bb 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -67,6 +67,8 @@ CURL_EXTERN int curl_accept(int s, void *addr, void *addrlen, /* FILE functions */ CURL_EXTERN FILE *curl_fopen(const char *file, const char *mode, int line, const char *source); +CURL_EXTERN FILE *curl_fdopen(int filedes, const char *mode, int line, + const char *source); CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #ifndef MEMDEBUG_NODEFINES @@ -117,6 +119,8 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #undef fopen #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__) +#undef fdopen +#define fdopen(file,mode) curl_fdopen(file,mode,__LINE__,__FILE__) #define fclose(file) curl_fclose(file,__LINE__,__FILE__) #endif /* MEMDEBUG_NODEFINES */ -- cgit v1.2.1 From 89367d47a87e8bead28e229d6822718b987fac95 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 13 Sep 2008 03:45:03 +0000 Subject: Disable tracking of fdopen() calls in the low-level memory leak tracking code when fdopen() is not available, to avoid compiler error. --- lib/memdebug.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 4e50ad1bb..8bfcc63b3 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -8,7 +8,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2006, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -67,8 +67,10 @@ CURL_EXTERN int curl_accept(int s, void *addr, void *addrlen, /* FILE functions */ CURL_EXTERN FILE *curl_fopen(const char *file, const char *mode, int line, const char *source); +#ifdef HAVE_FDOPEN CURL_EXTERN FILE *curl_fdopen(int filedes, const char *mode, int line, const char *source); +#endif CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #ifndef MEMDEBUG_NODEFINES -- cgit v1.2.1 From c2c800d8639b1f34a89548e6c26e6d805036dfdc Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 30 Oct 2008 19:02:23 +0000 Subject: Move curl_dofreeaddrinfo() and curl_dofreeaddrinfo() implementation from lib/hostip6.c to lib/curl_addrinfo.c and prototypes from lib/hostip.h to lib/curl_addrinfo.h --- lib/memdebug.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 8bfcc63b3..3ed911635 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -89,6 +89,7 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #define accept(sock,addr,len)\ curl_accept(sock,addr,len,__LINE__,__FILE__) +#ifdef HAVE_GETADDRINFO #if defined(getaddrinfo) && defined(__osf__) /* OSF/1 and Tru64 have getaddrinfo as a define already, so we cannot define our macro as for other platforms. Instead, we redefine the new name they @@ -100,17 +101,20 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #define getaddrinfo(host,serv,hint,res) \ curl_dogetaddrinfo(host,serv,hint,res,__LINE__,__FILE__) #endif +#endif /* HAVE_GETADDRINFO */ #ifdef HAVE_GETNAMEINFO #undef getnameinfo #define getnameinfo(sa,salen,host,hostlen,serv,servlen,flags) \ curl_dogetnameinfo(sa,salen,host,hostlen,serv,servlen,flags, __LINE__, \ __FILE__) -#endif +#endif /* HAVE_GETNAMEINFO */ +#ifdef HAVE_FREEADDRINFO #undef freeaddrinfo #define freeaddrinfo(data) \ curl_dofreeaddrinfo(data,__LINE__,__FILE__) +#endif /* HAVE_FREEADDRINFO */ /* sclose is probably already defined, redefine it! */ #undef sclose -- cgit v1.2.1 From 9770899a4bfb27ea73d0b0ee4be857ea1e47c4fd Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 21 Apr 2009 10:26:58 +0000 Subject: Moved potential inclusion of system's malloc.h and memory.h header files to setup_once.h. Inclusion of each header file is based on the definition of NEED_MALLOC_H and NEED_MEMORY_H respectively. --- lib/memdebug.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 3ed911635..4c84247b1 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -8,7 +8,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -41,9 +41,6 @@ #include #endif #include -#ifdef HAVE_MEMORY_H -#include -#endif #define logfile curl_debuglogfile -- cgit v1.2.1 From 2c0c05e96d8b611e1f5eedea518fa1a7857804c9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 19 Jun 2009 00:41:03 +0000 Subject: sclose() function-like macro definition used to close a socket, now solely based on HAVE_CLOSESOCKET and HAVE_CLOSESOCKET_CAMEL config file preprocessor definitions. --- lib/memdebug.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 4c84247b1..96cf4ad38 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -116,9 +116,6 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); /* sclose is probably already defined, redefine it! */ #undef sclose #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__) -/* ares-adjusted define: */ -#undef closesocket -#define closesocket(sockfd) curl_sclose(sockfd,__LINE__,__FILE__) #undef fopen #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__) -- cgit v1.2.1 From b476530755182f8fa19c1bccde1ea9c04c65454d Mon Sep 17 00:00:00 2001 From: Gunter Knauf Date: Wed, 15 Jul 2009 01:10:18 +0000 Subject: fixed typo. --- lib/memdebug.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 96cf4ad38..6e7e8d7f2 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -1,6 +1,6 @@ #ifdef CURLDEBUG -#ifndef _CURL_MEDEBUG_H -#define _CURL_MEDEBUG_H +#ifndef _CURL_MEMDEBUG_H +#define _CURL_MEMDEBUG_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -125,5 +125,5 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #endif /* MEMDEBUG_NODEFINES */ -#endif /* _CURL_MEDEBUG_H */ +#endif /* _CURL_MEMDEBUG_H */ #endif /* CURLDEBUG */ -- cgit v1.2.1 From 6a79b0e8591ec94adcc49809bf1ab8cf66f1bb41 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 28 Oct 2009 20:30:23 +0000 Subject: Since the NSS lib closes the socket the memory tracking system wrongly gets a false positive on a leaked socket, so this introduces a way to tell the system that the socket is indeed closed without explicitly closing it! --- lib/memdebug.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 6e7e8d7f2..57e89b1d4 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -57,6 +57,7 @@ CURL_EXTERN void curl_memlimit(long limit); /* file descriptor manipulators */ CURL_EXTERN int curl_socket(int domain, int type, int protocol, int line , const char *); +CURL_EXTERN int curl_mark_sclose(int sockfd, int, const char *source); CURL_EXTERN int curl_sclose(int sockfd, int, const char *source); CURL_EXTERN int curl_accept(int s, void *addr, void *addrlen, int line, const char *source); @@ -117,6 +118,8 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #undef sclose #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__) +#define fake_sclose(sockfd) curl_mark_sclose(sockfd,__LINE__,__FILE__) + #undef fopen #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__) #undef fdopen @@ -127,3 +130,7 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #endif /* _CURL_MEMDEBUG_H */ #endif /* CURLDEBUG */ + +#ifndef fake_sclose +#define fake_sclose(x) +#endif -- cgit v1.2.1 From 308497ffc636cb863c8d4a99f1c4cf7530b01f55 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 29 Oct 2009 04:02:21 +0000 Subject: Fix compiler warning: control reaches end of non-void function --- lib/memdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 57e89b1d4..ed1177b59 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -57,7 +57,7 @@ CURL_EXTERN void curl_memlimit(long limit); /* file descriptor manipulators */ CURL_EXTERN int curl_socket(int domain, int type, int protocol, int line , const char *); -CURL_EXTERN int curl_mark_sclose(int sockfd, int, const char *source); +CURL_EXTERN void curl_mark_sclose(int sockfd, int, const char *source); CURL_EXTERN int curl_sclose(int sockfd, int, const char *source); CURL_EXTERN int curl_accept(int s, void *addr, void *addrlen, int line, const char *source); -- cgit v1.2.1 From ccfe279117f197d2b3d0bb17bc754209024836a2 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 18 Jan 2010 20:22:04 +0000 Subject: Constantine Sapuntzakis enhancements to make memory tracking log file writing of messages atomic, on systems where an fwrite of a memory buffer is atomic. --- lib/memdebug.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index ed1177b59..417d1f429 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -54,6 +54,7 @@ CURL_EXTERN void curl_dofree(void *ptr, int line, const char *source); CURL_EXTERN char *curl_dostrdup(const char *str, int line, const char *source); CURL_EXTERN void curl_memdebug(const char *logname); CURL_EXTERN void curl_memlimit(long limit); +CURL_EXTERN void curl_memlog(const char *format, ...); /* file descriptor manipulators */ CURL_EXTERN int curl_socket(int domain, int type, int protocol, int line , const char *); -- cgit v1.2.1 From afdc3d81e9b9ee02ba428f97fe3c38c24c5b51db Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 19 Jan 2010 01:30:07 +0000 Subject: update copyright year notice --- lib/memdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 417d1f429..c67648391 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -8,7 +8,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms -- cgit v1.2.1 From 5b778a7ca4b09f7e50f00ab2624035bb9e4d3528 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 22 Feb 2010 23:28:56 +0000 Subject: fix socket data type and logging format in debug tracking socket functions --- lib/memdebug.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index c67648391..27351b5d8 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -57,11 +57,14 @@ CURL_EXTERN void curl_memlimit(long limit); CURL_EXTERN void curl_memlog(const char *format, ...); /* file descriptor manipulators */ -CURL_EXTERN int curl_socket(int domain, int type, int protocol, int line , const char *); -CURL_EXTERN void curl_mark_sclose(int sockfd, int, const char *source); -CURL_EXTERN int curl_sclose(int sockfd, int, const char *source); -CURL_EXTERN int curl_accept(int s, void *addr, void *addrlen, - int line, const char *source); +CURL_EXTERN curl_socket_t curl_socket(int domain, int type, int protocol, + int line , const char *source); +CURL_EXTERN void curl_mark_sclose(curl_socket_t sockfd, + int line , const char *source); +CURL_EXTERN int curl_sclose(curl_socket_t sockfd, + int line , const char *source); +CURL_EXTERN curl_socket_t curl_accept(curl_socket_t s, void *a, void *alen, + int line, const char *source); /* FILE functions */ CURL_EXTERN FILE *curl_fopen(const char *file, const char *mode, int line, -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- lib/memdebug.h | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 27351b5d8..56b9f12b2 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -21,7 +21,6 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - * $Id$ ***************************************************************************/ /* -- cgit v1.2.1 From b903186fa0189ff241d756d25d07fdfe9885ae49 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 20 Apr 2011 15:17:42 +0200 Subject: source cleanup: unify look, style and indent levels By the use of a the new lib/checksrc.pl script that checks that our basic source style rules are followed. --- lib/memdebug.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 56b9f12b2..77a4f4774 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -8,7 +8,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2010, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -47,8 +47,10 @@ extern FILE *logfile; /* memory functions */ CURL_EXTERN void *curl_domalloc(size_t size, int line, const char *source); -CURL_EXTERN void *curl_docalloc(size_t elements, size_t size, int line, const char *source); -CURL_EXTERN void *curl_dorealloc(void *ptr, size_t size, int line, const char *source); +CURL_EXTERN void *curl_docalloc(size_t elements, size_t size, int line, + const char *source); +CURL_EXTERN void *curl_dorealloc(void *ptr, size_t size, int line, + const char *source); CURL_EXTERN void curl_dofree(void *ptr, int line, const char *source); CURL_EXTERN char *curl_dostrdup(const char *str, int line, const char *source); CURL_EXTERN void curl_memdebug(const char *logname); -- cgit v1.2.1 From f1586cb4775681810afd8e6626e7842d459f3b85 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 26 Jul 2011 17:23:27 +0200 Subject: stdio.h, stdlib.h, string.h, stdarg.h and ctype.h inclusion done in setup_once.h --- lib/memdebug.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 77a4f4774..3dc481577 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -1,6 +1,6 @@ #ifdef CURLDEBUG -#ifndef _CURL_MEMDEBUG_H -#define _CURL_MEMDEBUG_H +#ifndef HEADER_CURL_MEMDEBUG_H +#define HEADER_CURL_MEMDEBUG_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -39,7 +39,6 @@ #ifdef HAVE_SYS_SOCKET_H #include #endif -#include #define logfile curl_debuglogfile @@ -133,7 +132,7 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #endif /* MEMDEBUG_NODEFINES */ -#endif /* _CURL_MEMDEBUG_H */ +#endif /* HEADER_CURL_MEMDEBUG_H */ #endif /* CURLDEBUG */ #ifndef fake_sclose -- cgit v1.2.1 From bcbac913d65275cc9e22534a8b4cda6994b75977 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 29 Jul 2011 13:25:52 +0200 Subject: socketpair() usage tracking to allow fd leak detection --- lib/memdebug.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 3dc481577..b18bb39da 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -65,6 +65,11 @@ CURL_EXTERN int curl_sclose(curl_socket_t sockfd, int line , const char *source); CURL_EXTERN curl_socket_t curl_accept(curl_socket_t s, void *a, void *alen, int line, const char *source); +#ifdef HAVE_SOCKETPAIR +CURL_EXTERN int curl_socketpair(int domain, int type, int protocol, + curl_socket_t socket_vector[2], + int line , const char *source); +#endif /* FILE functions */ CURL_EXTERN FILE *curl_fopen(const char *file, const char *mode, int line, @@ -90,6 +95,10 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #undef accept /* for those with accept as a macro */ #define accept(sock,addr,len)\ curl_accept(sock,addr,len,__LINE__,__FILE__) +#ifdef HAVE_SOCKETPAIR +#define socketpair(domain,type,protocol,socket_vector)\ + curl_socketpair(domain,type,protocol,socket_vector,__LINE__,__FILE__) +#endif #ifdef HAVE_GETADDRINFO #if defined(getaddrinfo) && defined(__osf__) -- cgit v1.2.1 From aaab5fa299e13c0c3abba929cb187a8ec3b006f9 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 20 Aug 2011 17:26:02 +0200 Subject: MemoryTracking: adjust initialization calling Calling of curl_memdebug() was still done with a pending free() --- lib/memdebug.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index b18bb39da..02df08877 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -32,14 +32,12 @@ #include -#ifdef HAVE_SYS_TYPES_H -#include -#endif - #ifdef HAVE_SYS_SOCKET_H #include #endif +#define CURL_MT_LOGFNAME_BUFSIZE 512 + #define logfile curl_debuglogfile extern FILE *logfile; -- cgit v1.2.1 From 9194e1700312f27c6e2abdfb1f604e130497e887 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 2 Sep 2011 19:40:53 +0200 Subject: MemoryTracking: fix logging of free() calls done where Curl_safefree is called Just internal stuff... Curl_safefree is now a macro defined in memdebug.h instead of a function prototyped in url.h and implemented in url.c, so inclusion of url.h is no longer required in order to simply use Curl_safefree. Provide definition of macro WHILE_FALSE in setup_once.h in order to allow other macros such as DEBUGF and DEBUGASSERT, and code using it, to compile without 'conditional expression is constant' warnings. The WHILE_FALSE stuff fixes 150+ MSVC compiler warnings. --- lib/memdebug.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 02df08877..a042bb474 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -1,6 +1,6 @@ -#ifdef CURLDEBUG #ifndef HEADER_CURL_MEMDEBUG_H #define HEADER_CURL_MEMDEBUG_H +#ifdef CURLDEBUG /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -139,9 +139,21 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); #endif /* MEMDEBUG_NODEFINES */ -#endif /* HEADER_CURL_MEMDEBUG_H */ #endif /* CURLDEBUG */ +/* +** Following section applies even when CURLDEBUG is not defined. +*/ + #ifndef fake_sclose -#define fake_sclose(x) +#define fake_sclose(x) do { } WHILE_FALSE #endif + +/* + * Curl_safefree defined as a macro to allow MemoryTracking feature + * to log free() calls at same location where Curl_safefree is used. + */ + +#define Curl_safefree(ptr) do {if((ptr)) free((ptr));} WHILE_FALSE + +#endif /* HEADER_CURL_MEMDEBUG_H */ -- cgit v1.2.1 From 6b75d2c2df7209919a70a29a4479625b62fb3c28 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sat, 3 Sep 2011 16:06:10 +0200 Subject: fix a bunch of MSVC compiler warnings --- lib/memdebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index a042bb474..6e778b4da 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -146,7 +146,7 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); */ #ifndef fake_sclose -#define fake_sclose(x) do { } WHILE_FALSE +#define fake_sclose(x) Curl_nop_stmt #endif /* -- cgit v1.2.1 From ff9d85872248f360aa76791b050872fb332a1ea0 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 15 Sep 2011 17:35:23 +0200 Subject: Make Curl_safefree() macro assign NULL to given pointer when free'd --- lib/memdebug.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/memdebug.h') diff --git a/lib/memdebug.h b/lib/memdebug.h index 6e778b4da..1e02645f9 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -152,8 +152,10 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source); /* * Curl_safefree defined as a macro to allow MemoryTracking feature * to log free() calls at same location where Curl_safefree is used. + * This macro also assigns NULL to given pointer when free'd. */ -#define Curl_safefree(ptr) do {if((ptr)) free((ptr));} WHILE_FALSE +#define Curl_safefree(ptr) \ + do {if((ptr)) {free((ptr)); (ptr) = NULL;}} WHILE_FALSE #endif /* HEADER_CURL_MEMDEBUG_H */ -- cgit v1.2.1