move unset into separate .h, call it from curl_setup.h always

This commit is contained in:
Viktor Szakats 2025-07-06 01:55:53 +02:00
parent c82ea317f5
commit 79941d4657
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
4 changed files with 62 additions and 41 deletions

View file

@ -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 \

59
lib/curl_mem_undef.h Normal file
View file

@ -0,0 +1,59 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, 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

View file

@ -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.
*/

View file

@ -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"