diff options
Diffstat (limited to 'source/core/slang-allocator.h')
| -rw-r--r-- | source/core/slang-allocator.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/source/core/slang-allocator.h b/source/core/slang-allocator.h index f25fd92c9..bc1b880f8 100644 --- a/source/core/slang-allocator.h +++ b/source/core/slang-allocator.h @@ -19,11 +19,9 @@ namespace Slang #elif defined(__CYGWIN__) return aligned_alloc(alignment, size); #else - void * rs = 0; + void* rs = nullptr; int succ = posix_memalign(&rs, alignment, size); - if (succ!=0) - rs = 0; - return rs; + return (succ == 0) ? rs : nullptr; #endif } @@ -66,18 +64,15 @@ namespace Slang // Helper utilties for calling allocators. template<typename T, int isPOD> - class Initializer - { - - }; + class Initializer; template<typename T> class Initializer<T, 0> { public: - static void initialize(T* buffer, int size) + static void initialize(T* buffer, Index size) { - for (int i = 0; i < size; i++) + for (Index i = 0; i < size; i++) new (buffer + i) T(); } }; @@ -85,8 +80,10 @@ namespace Slang class Initializer<T, 1> { public: - static void initialize(T* buffer, int size) + static void initialize(T* buffer, Index size) { + SLANG_UNUSED(buffer); + SLANG_UNUSED(size); // It's pod so no initialization required //for (int i = 0; i < size; i++) // new (buffer + i) T; @@ -116,6 +113,7 @@ namespace Slang } }; +#if 0 template<typename T> class AllocateMethod<T, StandardAllocator> { @@ -129,6 +127,7 @@ namespace Slang delete[] ptr; } }; +#endif } #endif |
