summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/corealloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/util/corealloc.h')
-rw-r--r--src/lib/util/corealloc.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/util/corealloc.h b/src/lib/util/corealloc.h
index 0eab4b5123e..2c1df6dd46c 100644
--- a/src/lib/util/corealloc.h
+++ b/src/lib/util/corealloc.h
@@ -27,7 +27,9 @@
// global allocation helpers -- use these instead of new and delete
#define global_alloc(_type) new _type
+#define global_alloc_nothrow(_type) new (std::nothrow) _type
#define global_alloc_array(_type, _num) new _type[_num]
+#define global_alloc_array_nothrow(_type, _num) new (std::nothrow) _type[_num]
#define global_free(_ptr) do { delete _ptr; } while (0)
#define global_free_array(_ptr) do { delete[] _ptr; } while (0)
@@ -35,15 +37,15 @@
template<typename _Tp, typename... _Args>
inline _Tp* global_alloc_clear(_Args&&... __args)
-{
+{
unsigned char * ptr = new unsigned char[sizeof(_Tp)]; // allocate memory
memset(ptr, 0, sizeof(_Tp));
- return new(ptr) _Tp(std::forward<_Args>(__args)...);
+ return new(ptr) _Tp(std::forward<_Args>(__args)...);
}
template<typename _Tp>
inline _Tp* global_alloc_array_clear(size_t __num)
-{
+{
auto size = sizeof(_Tp) * __num;
unsigned char* ptr = new unsigned char[size]; // allocate memory
memset(ptr, 0, size);