diff options
author | 2016-02-07 10:18:44 +0100 | |
---|---|---|
committer | 2016-02-07 10:18:44 +0100 | |
commit | 44f98845f7bd276a8db6a413e08981c2a44b1d38 (patch) | |
tree | 0d4547b361b228c17d535b2fa756ec0a52356e6b /src/lib/util/corealloc.h | |
parent | 38e15d788531b8eef8bc3d1c2c9814b9008f61e0 (diff) | |
parent | 5bc83a25063330ab9177a291ab984c5c7052aa02 (diff) |
Merge pull request #1 from mamedev/master
Update to 0.170
Diffstat (limited to 'src/lib/util/corealloc.h')
-rw-r--r-- | src/lib/util/corealloc.h | 8 |
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); |