From 6d35b1294e0570b76469b05e93afb8e8e4a465dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 10 Jun 2017 22:31:16 -0700 Subject: [PATCH] Cleanup. --- include/bx/config.h | 4 ---- include/bx/crtimpl.h | 19 +++++-------------- src/crtimpl.cpp | 14 +++++--------- tests/simd_bench.cpp | 2 +- tests/string_test.cpp | 2 +- tools/bin2c/bin2c.cpp | 2 +- 6 files changed, 13 insertions(+), 30 deletions(-) diff --git a/include/bx/config.h b/include/bx/config.h index afc7e9c..1df378d 100644 --- a/include/bx/config.h +++ b/include/bx/config.h @@ -12,10 +12,6 @@ # define BX_CONFIG_ALLOCATOR_DEBUG 0 #endif // BX_CONFIG_DEBUG_ALLOC -#ifndef BX_CONFIG_ALLOCATOR_CRT -# define BX_CONFIG_ALLOCATOR_CRT 1 -#endif // BX_CONFIG_ALLOCATOR_CRT - #ifndef BX_CONFIG_CRT_FILE_READER_WRITER # define BX_CONFIG_CRT_FILE_READER_WRITER !(0 \ || BX_CRT_NONE \ diff --git a/include/bx/crtimpl.h b/include/bx/crtimpl.h index c37ccb2..f9f1519 100644 --- a/include/bx/crtimpl.h +++ b/include/bx/crtimpl.h @@ -6,33 +6,24 @@ #ifndef BX_CRTIMPL_H_HEADER_GUARD #define BX_CRTIMPL_H_HEADER_GUARD -#include "bx.h" - -#if BX_CONFIG_ALLOCATOR_CRT -# include "allocator.h" -#endif // BX_CONFIG_ALLOCATOR_CRT - -#if BX_CONFIG_CRT_FILE_READER_WRITER -# include "readerwriter.h" -#endif // BX_CONFIG_CRT_FILE_READER_WRITER +#include "allocator.h" +#include "readerwriter.h" namespace bx { -#if BX_CONFIG_ALLOCATOR_CRT /// - class CrtAllocator : public AllocatorI + class DefaultAllocator : public AllocatorI { public: /// - CrtAllocator(); + DefaultAllocator(); /// - virtual ~CrtAllocator(); + virtual ~DefaultAllocator(); /// virtual void* realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line) BX_OVERRIDE; }; -#endif // BX_CONFIG_ALLOCATOR_CRT #if BX_CONFIG_CRT_FILE_READER_WRITER /// diff --git a/src/crtimpl.cpp b/src/crtimpl.cpp index 539ba83..d741f97 100644 --- a/src/crtimpl.cpp +++ b/src/crtimpl.cpp @@ -4,24 +4,21 @@ */ #include -#include -#if BX_CONFIG_ALLOCATOR_CRT -# include -#endif // BX_CONFIG_ALLOCATOR_CRT +#include +#include namespace bx { -#if BX_CONFIG_ALLOCATOR_CRT - CrtAllocator::CrtAllocator() + DefaultAllocator::DefaultAllocator() { } - CrtAllocator::~CrtAllocator() + DefaultAllocator::~DefaultAllocator() { } - void* CrtAllocator::realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line) + void* DefaultAllocator::realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line) { if (0 == _size) { @@ -70,7 +67,6 @@ namespace bx return bx::alignedRealloc(this, _ptr, _size, _align, _file, _line); # endif // BX_ } -#endif // BX_CONFIG_ALLOCATOR_CRT #if BX_CONFIG_CRT_FILE_READER_WRITER diff --git a/tests/simd_bench.cpp b/tests/simd_bench.cpp index d8ace20..1132111 100644 --- a/tests/simd_bench.cpp +++ b/tests/simd_bench.cpp @@ -98,7 +98,7 @@ void simd_bench_pass(bx::simd128_t* _dst, bx::simd128_t* _src, uint32_t _numVert void simd_bench() { - bx::CrtAllocator allocator; + bx::DefaultAllocator allocator; bx::RngMwc rng; const uint32_t numVertices = 1024*1024; diff --git a/tests/string_test.cpp b/tests/string_test.cpp index 167cdec..59f1380 100644 --- a/tests/string_test.cpp +++ b/tests/string_test.cpp @@ -187,7 +187,7 @@ TEST_CASE("StringView", "") bx::StringView sv("test"); REQUIRE(4 == sv.getLength() ); - bx::CrtAllocator crt; + bx::DefaultAllocator crt; g_allocator = &crt; typedef bx::StringT<&g_allocator> String; diff --git a/tools/bin2c/bin2c.cpp b/tools/bin2c/bin2c.cpp index 907605e..ac01da6 100644 --- a/tools/bin2c/bin2c.cpp +++ b/tools/bin2c/bin2c.cpp @@ -154,7 +154,7 @@ int main(int _argc, const char* _argv[]) { size = uint32_t(bx::getSize(&fr) ); - bx::CrtAllocator allocator; + bx::DefaultAllocator allocator; data = BX_ALLOC(&allocator, size); bx::read(&fr, data, size);