[clang] Headers: prefer `corecrt_malloc.h` to `malloc.h` (PR #131668)
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 17 13:47:12 PDT 2025
https://github.com/compnerd updated https://github.com/llvm/llvm-project/pull/131668
>From 8415be6e59aa2f8a23a3e484b1c8053f4d0c7206 Mon Sep 17 00:00:00 2001
From: Saleem Abdulrasool <abdulras at thebrowser.company>
Date: Mon, 17 Mar 2025 13:31:05 -0700
Subject: [PATCH] Headers: prefer `corecrt_malloc.h` to `malloc.h`
This allows us to target a lower level library (corecrt) rather than the
higher level library (ucrt) which can be helpful in modularising the
SDK.
---
clang/lib/Headers/mm_malloc.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Headers/mm_malloc.h b/clang/lib/Headers/mm_malloc.h
index d32fe59416277..addb598f62e45 100644
--- a/clang/lib/Headers/mm_malloc.h
+++ b/clang/lib/Headers/mm_malloc.h
@@ -13,7 +13,11 @@
#include <stdlib.h>
#ifdef _WIN32
-#include <malloc.h>
+# if defined(__MINGW32__)
+# include <malloc.h>
+# else
+# include <corecrt_malloc.h>
+# endif
#else
#ifndef __cplusplus
extern int posix_memalign(void **__memptr, size_t __alignment, size_t __size);
More information about the cfe-commits
mailing list