diff options
author | Curl Upstream <curl-library@cool.haxx.se> | 2017-10-04 05:52:15 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-10-10 15:15:03 (GMT) |
commit | de7c21d677db1ddaeece03c19e13e448f4031511 (patch) | |
tree | f812bbd3771bd01de9f7cd91a557766605f6ed2c /lib/memdebug.c | |
parent | 06d6d6c4aee149cd6560b919ef6935ef0867d921 (diff) | |
download | CMake-de7c21d677db1ddaeece03c19e13e448f4031511.zip CMake-de7c21d677db1ddaeece03c19e13e448f4031511.tar.gz CMake-de7c21d677db1ddaeece03c19e13e448f4031511.tar.bz2 |
curl 2017-10-04 (3ea76790)
Code extracted from:
https://github.com/curl/curl.git
at commit 3ea76790571c1f7cf1bed34fabffd3cc20ad3dd3 (curl-7_56_0).
Diffstat (limited to 'lib/memdebug.c')
-rw-r--r-- | lib/memdebug.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/memdebug.c b/lib/memdebug.c index 2b8808a..0eb249c 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -115,7 +115,8 @@ void curl_memdebug(const char *logname) logfile = stderr; #ifdef MEMDEBUG_LOG_SYNC /* Flush the log file after every line so the log isn't lost in a crash */ - setbuf(logfile, (char *)NULL); + if(logfile) + setbuf(logfile, (char *)NULL); #endif } } @@ -146,7 +147,7 @@ static bool countcheck(const char *func, int line, const char *source) source, line, func); fflush(logfile); /* because it might crash now */ } - SET_ERRNO(ENOMEM); + errno = ENOMEM; return TRUE; /* RETURN ERROR! */ } else @@ -169,7 +170,7 @@ void *curl_domalloc(size_t wantedsize, int line, const char *source) return NULL; /* alloc at least 64 bytes */ - size = sizeof(struct memdebug)+wantedsize; + size = sizeof(struct memdebug) + wantedsize; mem = (Curl_cmalloc)(size); if(mem) { @@ -224,9 +225,9 @@ char *curl_dostrdup(const char *str, int line, const char *source) if(countcheck("strdup", line, source)) return NULL; - len=strlen(str)+1; + len = strlen(str) + 1; - mem=curl_domalloc(len, 0, NULL); /* NULL prevents logging */ + mem = curl_domalloc(len, 0, NULL); /* NULL prevents logging */ if(mem) memcpy(mem, str, len); @@ -268,9 +269,9 @@ wchar_t *curl_dowcsdup(const wchar_t *str, int line, const char *source) void *curl_dorealloc(void *ptr, size_t wantedsize, int line, const char *source) { - struct memdebug *mem=NULL; + struct memdebug *mem = NULL; - size_t size = sizeof(struct memdebug)+wantedsize; + size_t size = sizeof(struct memdebug) + wantedsize; DEBUGASSERT(wantedsize != 0); @@ -406,7 +407,7 @@ void curl_mark_sclose(curl_socket_t sockfd, int line, const char *source) /* this is our own defined way to close sockets on *ALL* platforms */ int curl_sclose(curl_socket_t sockfd, int line, const char *source) { - int res=sclose(sockfd); + int res = sclose(sockfd); curl_mark_sclose(sockfd, line, source); return res; } @@ -414,7 +415,7 @@ int curl_sclose(curl_socket_t sockfd, int line, const char *source) FILE *curl_fopen(const char *file, const char *mode, int line, const char *source) { - FILE *res=fopen(file, mode); + FILE *res = fopen(file, mode); if(source) curl_memlog("FILE %s:%d fopen(\"%s\",\"%s\") = %p\n", @@ -427,7 +428,7 @@ FILE *curl_fopen(const char *file, const char *mode, FILE *curl_fdopen(int filedes, const char *mode, int line, const char *source) { - FILE *res=fdopen(filedes, mode); + FILE *res = fdopen(filedes, mode); if(source) curl_memlog("FILE %s:%d fdopen(\"%d\",\"%s\") = %p\n", @@ -443,7 +444,7 @@ int curl_fclose(FILE *file, int line, const char *source) DEBUGASSERT(file != NULL); - res=fclose(file); + res = fclose(file); if(source) curl_memlog("FILE %s:%d fclose(%p)\n", |