aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-12-19 13:23:54 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-12-19 13:23:54 +0000
commit5594741acbb6fb88ad840c6fa7ca328ff032497c (patch)
tree3d40f0f3adbee0b8bbf0b21f7e8251fa2131d1e4 /lib
parentcbaeed7232bc48a515756ba700561069729d1a3a (diff)
Added fopen() and fclose() leak tracking
Diffstat (limited to 'lib')
-rw-r--r--lib/memdebug.c16
-rw-r--r--lib/memdebug.h12
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/memdebug.c b/lib/memdebug.c
index 1bd945e0d..a92207f64 100644
--- a/lib/memdebug.c
+++ b/lib/memdebug.c
@@ -151,4 +151,20 @@ int curl_sclose(int sockfd, int line, char *source)
return sockfd;
}
+FILE *curl_fopen(char *file, char *mode, int line, char *source)
+{
+ FILE *res=(fopen)(file, mode);
+ fprintf(logfile?logfile:stderr, "FILE %s:%d fopen(\"%s\") = %p\n",
+ source, line, file, res);
+ return res;
+}
+
+int curl_fclose(FILE *file, int line, char *source)
+{
+ int res=(fclose)(file);
+ fprintf(logfile?logfile:stderr, "FILE %s:%d fclose(%p)\n",
+ source, line, file);
+ return res;
+}
+
#endif /* MALLOCDEBUG */
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 <sys/socket.h>
+#include <stdio.h>
+
/* 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