EXCLUDE_FROM_ALL
${HHEADERS} ${CSOURCES}
)
- target_compile_definitions(curlu PUBLIC "UNITTESTS" "CURL_STATICLIB")
+ target_compile_definitions(curlu PUBLIC "CURL_STATICLIB" "UNITTESTS")
target_link_libraries(curlu PRIVATE ${CURL_LIBS})
# There is plenty of parallelism when building the testdeps target.
# Override the curlu batch size with the maximum to optimize performance.
endif()
if(ENABLE_CURLDEBUG)
- # We must compile these sources separately to avoid memdebug.h redefinitions
- # applying to them.
- set_source_files_properties("memdebug.c" "curl_multibyte.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
+ # We must compile this source separately to avoid memdebug.h redefinitions
+ # applying to it.
+ set_source_files_properties("memdebug.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
endif()
## Library definition
# in static mode.
curl_EXCLUDE = curl_threads.c timediff.c warnless.c
if CURLDEBUG
-# We must compile these sources separately to avoid memdebug.h redefinitions
-# applying to them.
-curl_EXCLUDE += memdebug.c curl_multibyte.c
+# We must compile this source separately to avoid memdebug.h redefinitions
+# applying to it.
+curl_EXCLUDE += memdebug.c
endif
# For Cygwin always compile dllmain.c as a separate unit since it
# includes windows.h, which should not be included in other units.
***************************************************************************/
/*
- * This file is 'mem-include-scan' clean, which means memdebug.h and
- * curl_memory.h are purposely not included in this file. See test 1132.
- *
- * The functions in this file are curlx functions which are not tracked by the
- * curl memory tracker memdebug.
+ * This file is 'mem-include-scan' clean, which means its memory allocations
+ * are not tracked by the curl memory tracker memdebug, so they must not use
+ * `CURLDEBUG` macro replacements in memdebug.h for free, malloc, etc. To avoid
+ * these macro replacements, wrap the names in parentheses to call the original
+ * versions: `ptr = (malloc)(123)`, `(free)(ptr)`, etc.
*/
#include "curl_setup.h"
int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
str_utf8, -1, NULL, 0);
if(str_w_len > 0) {
- str_w = malloc(str_w_len * sizeof(wchar_t));
+ str_w = (malloc)(str_w_len * sizeof(wchar_t));
if(str_w) {
if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w,
str_w_len) == 0) {
- free(str_w);
+ (free)(str_w);
return NULL;
}
}
int bytes = WideCharToMultiByte(CP_UTF8, 0, str_w, -1,
NULL, 0, NULL, NULL);
if(bytes > 0) {
- str_utf8 = malloc(bytes);
+ str_utf8 = (malloc)(bytes);
if(str_utf8) {
if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, bytes,
NULL, NULL) == 0) {
- free(str_utf8);
+ (free)(str_utf8);
return NULL;
}
}
if(needed == (size_t)-1 || needed >= max_path_len)
goto cleanup;
++needed; /* for NUL */
- ibuf = malloc(needed * sizeof(wchar_t));
+ ibuf = (malloc)(needed * sizeof(wchar_t));
if(!ibuf)
goto cleanup;
count = mbstowcs(ibuf, in, needed);
/* skip paths that are not excessive and do not need modification */
if(needed <= MAX_PATH)
goto cleanup;
- fbuf = malloc(needed * sizeof(wchar_t));
+ fbuf = (malloc)(needed * sizeof(wchar_t));
if(!fbuf)
goto cleanup;
count = (size_t)GetFullPathNameW(in_w, (DWORD)needed, fbuf, NULL);
if(needed > max_path_len)
goto cleanup;
- temp = malloc(needed * sizeof(wchar_t));
+ temp = (malloc)(needed * sizeof(wchar_t));
if(!temp)
goto cleanup;
if(needed > max_path_len)
goto cleanup;
- temp = malloc(needed * sizeof(wchar_t));
+ temp = (malloc)(needed * sizeof(wchar_t));
if(!temp)
goto cleanup;
wcscpy(temp + 4, fbuf);
}
- free(fbuf);
+ (free)(fbuf);
fbuf = temp;
}
if(needed == (size_t)-1 || needed >= max_path_len)
goto cleanup;
++needed; /* for NUL */
- obuf = malloc(needed);
+ obuf = (malloc)(needed);
if(!obuf)
goto cleanup;
count = wcstombs(obuf, fbuf, needed);
#endif
cleanup:
- free(fbuf);
+ (free)(fbuf);
#ifndef _UNICODE
- free(ibuf);
- free(obuf);
+ (free)(ibuf);
+ (free)(obuf);
#endif
return *out ? true : false;
}
target = fixed;
else
target = filename;
- result = (_open)(target, oflag, pmode);
+ result = _open(target, oflag, pmode);
#endif
- free(fixed);
+ (free)(fixed);
return result;
}
result = (fopen)(target, mode);
#endif
- free(fixed);
+ (free)(fixed);
return result;
}
#endif
#endif
- free(fixed);
+ (free)(fixed);
return result;
}
set(CURLX_CFILES ${CURLTOOL_LIBCURL_CFILES})
endif()
-if(ENABLE_CURLDEBUG)
- # We must compile this source separately to avoid memdebug.h redefinitions
- # applying to them.
- set_source_files_properties("../lib/curl_multibyte.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
-endif()
-
add_executable(
${EXE_NAME}
${CURL_CFILES} ${_curl_cfiles_gen} ${CURLX_CFILES} ${CURL_HFILES} ${_curl_hfiles_gen}
EXCLUDE_FROM_ALL
${CURL_CFILES} ${CURLTOOL_LIBCURL_CFILES} ${CURL_HFILES}
)
-target_compile_definitions(curltool PUBLIC "UNITTESTS" "CURL_STATICLIB")
+target_compile_definitions(curltool PUBLIC "CURL_STATICLIB" "UNITTESTS")
target_link_libraries(curltool PRIVATE ${CURL_LIBS})
if(CURL_HAS_LTO)
CLEANFILES =
if USE_UNITY
-curl_EXCLUDE =
-if CURLDEBUG
-# We must compile this source separately to avoid memdebug.h redefinitions
-# applying to them.
-curl_EXCLUDE += ../lib/curl_multibyte.c
-endif
if USE_CPPFLAG_CURL_STATICLIB
curl_CURLX = $(CURLTOOL_LIBCURL_CFILES)
else
curl_CURLX = $(CURLX_CFILES)
endif
curltool_unity.c: $(top_srcdir)/scripts/mk-unity.pl $(CURL_CFILES) $(curl_cfiles_gen) $(curl_CURLX)
- @PERL@ $(top_srcdir)/scripts/mk-unity.pl $(srcdir) $(CURL_CFILES) $(curl_cfiles_gen) $(curl_CURLX) --exclude $(curl_EXCLUDE) > curltool_unity.c
+ @PERL@ $(top_srcdir)/scripts/mk-unity.pl $(srcdir) $(CURL_CFILES) $(curl_cfiles_gen) $(curl_CURLX) > curltool_unity.c
nodist_curl_SOURCES = curltool_unity.c
-curl_SOURCES = $(curl_EXCLUDE)
+curl_SOURCES =
CLEANFILES += curltool_unity.c
else
# CURL_FILES comes from Makefile.inc
libcurltool_la_LDFLAGS = -static $(LINKFLAGS)
if USE_UNITY
libcurltool_unity.c: $(top_srcdir)/scripts/mk-unity.pl $(CURL_CFILES) $(CURLTOOL_LIBCURL_CFILES)
- @PERL@ $(top_srcdir)/scripts/mk-unity.pl $(srcdir) $(CURL_CFILES) $(CURLTOOL_LIBCURL_CFILES) --exclude $(curl_EXCLUDE) > libcurltool_unity.c
+ @PERL@ $(top_srcdir)/scripts/mk-unity.pl $(srcdir) $(CURL_CFILES) $(CURLTOOL_LIBCURL_CFILES) > libcurltool_unity.c
nodist_libcurltool_la_SOURCES = libcurltool_unity.c
-libcurltool_la_SOURCES = $(curl_EXCLUDE)
+libcurltool_la_SOURCES =
CLEANFILES += libcurltool_unity.c
else
libcurltool_la_SOURCES = $(CURL_FILES)
curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
-if(ENABLE_CURLDEBUG)
- set_source_files_properties("../../lib/curl_multibyte.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
-endif()
-
add_custom_command(
OUTPUT "lib1521.c"
COMMAND ${PERL_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/mk-lib1521.pl" < "${PROJECT_SOURCE_DIR}/include/curl/curl.h" "lib1521.c"
include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
if(ENABLE_SERVER_DEBUG AND ENABLE_CURLDEBUG)
- set_source_files_properties("../../lib/memdebug.c" "../../lib/curl_multibyte.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
+ set_source_files_properties("../../lib/memdebug.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
endif()
if(CURL_TEST_BUNDLES)
SERVERPROGS = resolve rtspd sockfilt sws tftpd socksd disabled mqttd
MEMDEBUG = \
- ../../lib/curl_multibyte.c \
- ../../lib/curl_multibyte.h \
../../lib/memdebug.c \
../../lib/memdebug.h
../../lib/strcase.c \
../../lib/strdup.c \
../../lib/curl_get_line.c \
+ ../../lib/curl_multibyte.c \
../../lib/version_win32.c
CURLX_HDRS = \
../../lib/strcase.h \
../../lib/strdup.h \
../../lib/curl_get_line.h \
+ ../../lib/curl_multibyte.h \
../../lib/version_win32.h
UTIL = \