diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-06-15 15:54:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-06-15 15:54:35 -0700 |
| commit | 1353a7854a738ae173aa1b2f3361f54b82757095 (patch) | |
| tree | 199e9a54596c572015c7b0652e62b941418f483f /source/core/allocator.h | |
| parent | c34a433d7aa3fdbfefee22f20d5aac2d960f392a (diff) | |
| parent | 04d43cd71f081f1b8d2f0fd803a47cb6342e4fcd (diff) | |
Merge pull request #26 from tfoleyNV/cleanup
Cleanup
Diffstat (limited to 'source/core/allocator.h')
| -rw-r--r-- | source/core/allocator.h | 79 |
1 files changed, 38 insertions, 41 deletions
diff --git a/source/core/allocator.h b/source/core/allocator.h index d4dfcf5a9..46550a054 100644 --- a/source/core/allocator.h +++ b/source/core/allocator.h @@ -3,60 +3,57 @@ #include <stdlib.h> -namespace CoreLib +namespace Slang { - namespace Basic + inline void * AlignedAlloc(size_t size, size_t alignment) { - inline void * AlignedAlloc(size_t size, size_t alignment) - { #ifdef _MSC_VER - return _aligned_malloc(size, alignment); + return _aligned_malloc(size, alignment); #else - void * rs = 0; - int succ = posix_memalign(&rs, alignment, size); - if (succ!=0) - rs = 0; - return rs; + void * rs = 0; + int succ = posix_memalign(&rs, alignment, size); + if (succ!=0) + rs = 0; + return rs; #endif - } + } - inline void AlignedFree(void * ptr) - { + inline void AlignedFree(void * ptr) + { #ifdef _MSC_VER - _aligned_free(ptr); + _aligned_free(ptr); #else - free(ptr); + free(ptr); #endif - } + } - class StandardAllocator + class StandardAllocator + { + public: + // not really called + void * Alloc(size_t size) { - public: - // not really called - void * Alloc(size_t size) - { - return malloc(size); - } - void Free(void * ptr) - { - return free(ptr); - } - }; + return malloc(size); + } + void Free(void * ptr) + { + return free(ptr); + } + }; - template<int alignment> - class AlignedAllocator + template<int alignment> + class AlignedAllocator + { + public: + void * Alloc(size_t size) { - public: - void * Alloc(size_t size) - { - return AlignedAlloc(size, alignment); - } - void Free(void * ptr) - { - return AlignedFree(ptr); - } - }; - } + return AlignedAlloc(size, alignment); + } + void Free(void * ptr) + { + return AlignedFree(ptr); + } + }; } #endif
\ No newline at end of file |
