From 25189ad927271b3df46ea9b684566d78d5ff129f Mon Sep 17 00:00:00 2001 From: Andrew Gallagher Date: Wed, 11 Jul 2012 14:03:19 -0700 Subject: [PATCH] folly/Malloc.h: use libstdc++-safe exception wrappers Summary: gcc errors out when code that throws is compiled with '-fno-exceptions'. Since we add Malloc.h into our custom libstdc++ use the exception wrappers from functexcept.h so that they can build with third-party projects that use '-fno-exceptions'. Test Plan: Built llvm in the gcc-4.7.1-glibc-2.14.1-fb platform with these changes. Reviewed By: tudorb@fb.com FB internal diff: D516577 --- folly/Malloc.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/folly/Malloc.h b/folly/Malloc.h index 7aadfc8f..e43c2afe 100644 --- a/folly/Malloc.h +++ b/folly/Malloc.h @@ -62,6 +62,8 @@ namespace folly { #include +#include + /** * Declare rallocm() and malloc_usable_size() as weak symbols. It * will be provided by jemalloc if we are using jemalloc, or it will @@ -144,19 +146,19 @@ static const size_t jemallocMinInPlaceExpandable = 4096; */ inline void* checkedMalloc(size_t size) { void* p = malloc(size); - if (!p) throw std::bad_alloc(); + if (!p) std::__throw_bad_alloc(); return p; } inline void* checkedCalloc(size_t n, size_t size) { void* p = calloc(n, size); - if (!p) throw std::bad_alloc(); + if (!p) std::__throw_bad_alloc(); return p; } inline void* checkedRealloc(void* ptr, size_t size) { void* p = realloc(ptr, size); - if (!p) throw std::bad_alloc(); + if (!p) std::__throw_bad_alloc(); return p; } -- 2.34.1