mirror of
https://github.com/moparisthebest/curl
synced 2024-11-11 12:05:06 -05:00
Added fopen() and fclose() leak tracking
This commit is contained in:
parent
cbaeed7232
commit
5594741acb
@ -151,4 +151,20 @@ int curl_sclose(int sockfd, int line, char *source)
|
|||||||
return sockfd;
|
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 */
|
#endif /* MALLOCDEBUG */
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
#ifdef MALLOCDEBUG
|
#ifdef MALLOCDEBUG
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
/* memory functions */
|
/* memory functions */
|
||||||
void *curl_domalloc(size_t size, int line, char *source);
|
void *curl_domalloc(size_t size, int line, char *source);
|
||||||
void *curl_dorealloc(void *ptr, 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 curl_accept(int s, struct sockaddr *addr, int *addrlen,
|
||||||
int line, char *source);
|
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 */
|
/* Set this symbol on the command-line, recompile all lib-sources */
|
||||||
#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
|
#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
|
||||||
#define malloc(size) curl_domalloc(size, __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
|
#undef sclose
|
||||||
#define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
|
#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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user