aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/curl/lib/memdebug.c
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2024-10-11 21:07:18 +0300
committerthegeorg <thegeorg@yandex-team.com>2024-10-11 21:17:24 +0300
commit1df197e6035ea9826bfedee7d48812e318ba9c7a (patch)
tree76b8e9de41820755adf209854d06a84a8b5a1988 /contrib/libs/curl/lib/memdebug.c
parentf9c007ea1b59b960201def74990810b26ecdfd48 (diff)
downloadydb-1df197e6035ea9826bfedee7d48812e318ba9c7a.tar.gz
Revert "Update contrib/libs/curl to 8.10.1" to fix
Revert "Update contrib/libs/curl to 8.10.1" This reverts commit 428ef806a15515cdaa325530aa8cc6903fac5fb6, reversing changes made to 40e46e6394df409d1545a3771c8a47a86ed55eac. Revert "Fix formatting after rXXXXXX" This reverts commit a73689311a92e195d14136c5a0049ef1e40b1f3e, reversing changes made to 17980b8756d1f74d3dacddc7ca4945c30f35611c. commit_hash:5c5194831e5455b61fbee61619066396626beab1
Diffstat (limited to 'contrib/libs/curl/lib/memdebug.c')
-rw-r--r--contrib/libs/curl/lib/memdebug.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/contrib/libs/curl/lib/memdebug.c b/contrib/libs/curl/lib/memdebug.c
index bc83d3eea3..f6ced85cd9 100644
--- a/contrib/libs/curl/lib/memdebug.c
+++ b/contrib/libs/curl/lib/memdebug.c
@@ -30,7 +30,7 @@
#include "urldata.h"
-#define MEMDEBUG_NODEFINES /* do not redefine the standard functions */
+#define MEMDEBUG_NODEFINES /* don't redefine the standard functions */
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -44,8 +44,8 @@ struct memdebug {
double d;
void *p;
} mem[1];
- /* I am hoping this is the thing with the strictest alignment
- * requirements. That also means we waste some space :-( */
+ /* I'm hoping this is the thing with the strictest alignment
+ * requirements. That also means we waste some space :-( */
};
/*
@@ -53,7 +53,7 @@ struct memdebug {
* remain so. For advanced analysis, record a log file and write perl scripts
* to analyze them!
*
- * Do not use these with multithreaded test programs!
+ * Don't use these with multithreaded test programs!
*/
FILE *curl_dbg_logfile = NULL;
@@ -75,7 +75,7 @@ static void curl_dbg_cleanup(void)
curl_dbg_logfile = NULL;
}
-/* this sets the log filename */
+/* this sets the log file name */
void curl_dbg_memdebug(const char *logname)
{
if(!curl_dbg_logfile) {
@@ -84,7 +84,7 @@ void curl_dbg_memdebug(const char *logname)
else
curl_dbg_logfile = stderr;
#ifdef MEMDEBUG_LOG_SYNC
- /* Flush the log file after every line so the log is not lost in a crash */
+ /* Flush the log file after every line so the log isn't lost in a crash */
if(curl_dbg_logfile)
setbuf(curl_dbg_logfile, (char *)NULL);
#endif
@@ -103,7 +103,7 @@ void curl_dbg_memlimit(long limit)
}
}
-/* returns TRUE if this is not allowed! */
+/* returns TRUE if this isn't allowed! */
static bool countcheck(const char *func, int line, const char *source)
{
/* if source is NULL, then the call is made internally and this check
@@ -304,6 +304,12 @@ void curl_dbg_free(void *ptr, int line, const char *source)
curl_socket_t curl_dbg_socket(int domain, int type, int protocol,
int line, const char *source)
{
+ const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
+ "FD %s:%d socket() = %d\n" :
+ (sizeof(curl_socket_t) == sizeof(long)) ?
+ "FD %s:%d socket() = %ld\n" :
+ "FD %s:%d socket() = %zd\n";
+
curl_socket_t sockfd;
if(countcheck("socket", line, source))
@@ -312,8 +318,7 @@ curl_socket_t curl_dbg_socket(int domain, int type, int protocol,
sockfd = socket(domain, type, protocol);
if(source && (sockfd != CURL_SOCKET_BAD))
- curl_dbg_log("FD %s:%d socket() = %" FMT_SOCKET_T "\n",
- source, line, sockfd);
+ curl_dbg_log(fmt, source, line, sockfd);
return sockfd;
}
@@ -352,12 +357,16 @@ int curl_dbg_socketpair(int domain, int type, int protocol,
curl_socket_t socket_vector[2],
int line, const char *source)
{
+ const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
+ "FD %s:%d socketpair() = %d %d\n" :
+ (sizeof(curl_socket_t) == sizeof(long)) ?
+ "FD %s:%d socketpair() = %ld %ld\n" :
+ "FD %s:%d socketpair() = %zd %zd\n";
+
int res = socketpair(domain, type, protocol, socket_vector);
if(source && (0 == res))
- curl_dbg_log("FD %s:%d socketpair() = "
- "%" FMT_SOCKET_T " %" FMT_SOCKET_T "\n",
- source, line, socket_vector[0], socket_vector[1]);
+ curl_dbg_log(fmt, source, line, socket_vector[0], socket_vector[1]);
return res;
}
@@ -366,14 +375,19 @@ int curl_dbg_socketpair(int domain, int type, int protocol,
curl_socket_t curl_dbg_accept(curl_socket_t s, void *saddr, void *saddrlen,
int line, const char *source)
{
+ const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
+ "FD %s:%d accept() = %d\n" :
+ (sizeof(curl_socket_t) == sizeof(long)) ?
+ "FD %s:%d accept() = %ld\n" :
+ "FD %s:%d accept() = %zd\n";
+
struct sockaddr *addr = (struct sockaddr *)saddr;
curl_socklen_t *addrlen = (curl_socklen_t *)saddrlen;
curl_socket_t sockfd = accept(s, addr, addrlen);
if(source && (sockfd != CURL_SOCKET_BAD))
- curl_dbg_log("FD %s:%d accept() = %" FMT_SOCKET_T "\n",
- source, line, sockfd);
+ curl_dbg_log(fmt, source, line, sockfd);
return sockfd;
}
@@ -381,9 +395,14 @@ curl_socket_t curl_dbg_accept(curl_socket_t s, void *saddr, void *saddrlen,
/* separate function to allow libcurl to mark a "faked" close */
void curl_dbg_mark_sclose(curl_socket_t sockfd, int line, const char *source)
{
+ const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
+ "FD %s:%d sclose(%d)\n":
+ (sizeof(curl_socket_t) == sizeof(long)) ?
+ "FD %s:%d sclose(%ld)\n":
+ "FD %s:%d sclose(%zd)\n";
+
if(source)
- curl_dbg_log("FD %s:%d sclose(%" FMT_SOCKET_T ")\n",
- source, line, sockfd);
+ curl_dbg_log(fmt, source, line, sockfd);
}
/* this is our own defined way to close sockets on *ALL* platforms */