diff options
author | James Housley <jim@thehousleys.net> | 2007-06-28 11:11:29 +0000 |
---|---|---|
committer | James Housley <jim@thehousleys.net> | 2007-06-28 11:11:29 +0000 |
commit | aed0cc6f2a9a7fdaae08ad6700687f7200b4ebaa (patch) | |
tree | 5ef37d17b276e70f2b924243d6058d4681b8d02a /lib | |
parent | d500c468fc99816a7bdd817404aa489b065ae64d (diff) |
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().
Diffstat (limited to 'lib')
-rw-r--r-- | lib/file.c | 3 | ||||
-rw-r--r-- | lib/memdebug.c | 10 | ||||
-rw-r--r-- | lib/memdebug.h | 4 |
3 files changed, 15 insertions, 2 deletions
diff --git a/lib/file.c b/lib/file.c index cec98986b..4cab1f1b9 100644 --- a/lib/file.c +++ b/lib/file.c @@ -231,8 +231,7 @@ static CURLcode file_upload(struct connectdata *conn) failf(data, "Can't open %s for writing", file->path); return CURLE_WRITE_ERROR; } - close(fd); - fp = fopen(file->path, "wb"); + fp = fdopen(fd, "wb"); } if(!fp) { diff --git a/lib/memdebug.c b/lib/memdebug.c index 582387cf9..2eb4c5afb 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -280,6 +280,16 @@ FILE *curl_fopen(const char *file, const char *mode, return res; } +FILE *curl_fdopen(int filedes, const char *mode, + int line, const char *source) +{ + FILE *res=(fdopen)(filedes, mode); + if(logfile) + fprintf(logfile, "FILE %s:%d fdopen(\"%d\",\"%s\") = %p\n", + source, line, filedes, mode, res); + return res; +} + int curl_fclose(FILE *file, int line, const char *source) { int res; 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 */ |