From 79941d46571f720300cb46f6d186f3b4268fc482 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 6 Jul 2025 01:55:53 +0200 Subject: [PATCH] move unset into separate .h, call it from curl_setup.h always --- lib/Makefile.inc | 1 + lib/curl_mem_undef.h | 59 ++++++++++++++++++++++++++++++++++++++++++++ lib/curl_memory.h | 41 ------------------------------ lib/curl_setup.h | 2 ++ 4 files changed, 62 insertions(+), 41 deletions(-) create mode 100644 lib/curl_mem_undef.h diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 257e104de9..c27b7e1894 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -296,6 +296,7 @@ LIB_HFILES = \ curl_ldap.h \ curl_md4.h \ curl_md5.h \ + curl_mem_undef.h \ curl_memory.h \ curl_memrchr.h \ curl_ntlm_core.h \ diff --git a/lib/curl_mem_undef.h b/lib/curl_mem_undef.h new file mode 100644 index 0000000000..4a9a03e248 --- /dev/null +++ b/lib/curl_mem_undef.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +/* Unset redefined system symbols. */ + +#undef strdup +#undef malloc +#undef calloc +#undef realloc +#undef free +#undef send +#undef recv + +#ifdef _WIN32 +#undef _tcsdup +#endif + +#undef socket +#undef accept +#ifdef HAVE_ACCEPT4 +#undef accept4 +#endif +#ifdef HAVE_SOCKETPAIR +#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) +#endif +#undef fdopen +#undef fclose + +#undef HEADER_CURL_MEMORY_H +#undef HEADER_CURL_MEMDEBUG_H diff --git a/lib/curl_memory.h b/lib/curl_memory.h index 3aa7c51fce..1fbe3db192 100644 --- a/lib/curl_memory.h +++ b/lib/curl_memory.h @@ -54,47 +54,6 @@ * */ -#ifdef HEADER_CURL_MEMDEBUG_H -/* cleanup after memdebug.h */ - -#ifdef CURLDEBUG - -#undef strdup -#undef malloc -#undef calloc -#undef realloc -#undef free -#undef send -#undef recv - -#ifdef _WIN32 -#undef _tcsdup -#endif - -#undef socket -#undef accept -#ifdef HAVE_ACCEPT4 -#undef accept4 -#endif -#ifdef HAVE_SOCKETPAIR -#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) -#endif -#undef fdopen -#undef fclose - -#endif /* CURLDEBUG */ - -#undef HEADER_CURL_MEMDEBUG_H -#endif /* HEADER_CURL_MEMDEBUG_H */ - /* ** Following section applies even when CURLDEBUG is not defined. */ diff --git a/lib/curl_setup.h b/lib/curl_setup.h index ba91206c3e..4e8dbfa63d 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -1171,3 +1171,5 @@ int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf, #endif #endif /* HEADER_CURL_SETUP_H */ + +#include "curl_mem_undef.h"