[libc++abi] Remove uses of C++ headers when possible
This reduces the (circular) dependency of libc++abi on a C++ standard
library. Outside of the demangler which uses fancier C++ features, the
only C++ headers now required by libc++abi are pretty much <new> and
<exception>, and that's because libc++abi defines some types that are
declared in those headers.
llvm-svn: 373381
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 04501a22a073d0f64e980aaa8c895a6e86c0a103
diff --git a/src/fallback_malloc.cpp b/src/fallback_malloc.cpp
index 9d62407..8f301bc 100644
--- a/src/fallback_malloc.cpp
+++ b/src/fallback_malloc.cpp
@@ -18,8 +18,8 @@
#endif
#endif
-#include <cstdlib> // for malloc, calloc, free
-#include <cstring> // for memset
+#include <stdlib.h> // for malloc, calloc, free
+#include <string.h> // for memset
// A small, simple heap manager based (loosely) on
// the startup heap manager from FreeBSD, optimized for space.
@@ -214,7 +214,7 @@
if (void* dest = _aligned_malloc(size, alignof(__aligned_type)))
return dest;
#elif defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)
- if (void* dest = std::malloc(size))
+ if (void* dest = ::malloc(size))
return dest;
#else
if (size == 0)
@@ -227,13 +227,13 @@
}
void* __calloc_with_fallback(size_t count, size_t size) {
- void* ptr = std::calloc(count, size);
+ void* ptr = ::calloc(count, size);
if (NULL != ptr)
return ptr;
// if calloc fails, fall back to emergency stash
ptr = fallback_malloc(size * count);
if (NULL != ptr)
- std::memset(ptr, 0, size * count);
+ ::memset(ptr, 0, size * count);
return ptr;
}
@@ -244,7 +244,7 @@
#if defined(_WIN32)
::_aligned_free(ptr);
#else
- std::free(ptr);
+ ::free(ptr);
#endif
}
}
@@ -253,7 +253,7 @@
if (is_fallback_ptr(ptr))
fallback_free(ptr);
else
- std::free(ptr);
+ ::free(ptr);
}
} // namespace __cxxabiv1