From 0cef0cb645901002258041ee773cd88210931d28 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 7 Jul 2025 12:07:36 +0200 Subject: [PATCH] move sclose/fake_sclose defs to curl_setup.h drop the undef/refer dance, it's unnecessary. --- lib/curl_mem_undef.h | 6 ------ lib/curl_setup.h | 11 +++++++++-- lib/curl_setup_once.h | 2 -- lib/memdebug.h | 7 ------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/lib/curl_mem_undef.h b/lib/curl_mem_undef.h index 00f0c6a564..1cfa43d9bc 100644 --- a/lib/curl_mem_undef.h +++ b/lib/curl_mem_undef.h @@ -45,9 +45,6 @@ #undef socketpair #endif -/* sclose is probably already defined, redefine it! */ -#undef sclose -#define sclose(x) CURL_SCLOSE(x) #undef fopen #ifdef CURL_FOPEN #define fopen(fname, mode) CURL_FOPEN(fname, mode) @@ -55,8 +52,5 @@ #undef fdopen #undef fclose -#undef fake_sclose -#define fake_sclose(x) Curl_nop_stmt - #undef HEADER_CURL_MEMORY_H #undef HEADER_CURL_MEMDEBUG_H diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 4e8dbfa63d..68f2284d27 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -1077,14 +1077,21 @@ CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode, int line, const char *source); +#define sclose(sockfd) curl_dbg_sclose(sockfd,__LINE__,__FILE__) +#define fake_sclose(sockfd) curl_dbg_mark_sclose(sockfd,__LINE__,__FILE__) #define CURL_GETADDRINFO(host,serv,hint,res) \ curl_dbg_getaddrinfo(host, serv, hint, res, __LINE__, __FILE__) #define CURL_FREEADDRINFO(data) \ curl_dbg_freeaddrinfo(data, __LINE__, __FILE__) -#else + +#else /* !CURLDEBUG */ + +#define sclose(x) CURL_SCLOSE(x) +#define fake_sclose(x) Curl_nop_stmt #define CURL_GETADDRINFO getaddrinfo #define CURL_FREEADDRINFO freeaddrinfo -#endif + +#endif /* CURLDEBUG */ /* Some versions of the Android NDK is missing the declaration */ #if defined(HAVE_GETPWUID_R) && \ diff --git a/lib/curl_setup_once.h b/lib/curl_setup_once.h index bec45de888..642e1487c8 100644 --- a/lib/curl_setup_once.h +++ b/lib/curl_setup_once.h @@ -206,8 +206,6 @@ struct timeval { # define CURL_SCLOSE(x) close((x)) #endif -#define sclose(x) CURL_SCLOSE(x) - /* * Stack-independent version of fcntl() on sockets: */ diff --git a/lib/memdebug.h b/lib/memdebug.h index 3edab05248..d8d5f807d7 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -73,13 +73,6 @@ __LINE__, __FILE__) #endif -/* sclose is probably already defined, redefine it! */ -#undef sclose -#define sclose(sockfd) curl_dbg_sclose(sockfd,__LINE__,__FILE__) - -#undef fake_sclose -#define fake_sclose(sockfd) curl_dbg_mark_sclose(sockfd,__LINE__,__FILE__) - #undef fopen #define fopen(file,mode) curl_dbg_fopen(file,mode,__LINE__,__FILE__) #undef fdopen