From 6d2d04cad53de5e17f7efd0374cfd859d32efe28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sun, 8 Feb 2015 10:25:53 -0800 Subject: [PATCH] Cleanup. --- examples/common/entry/cmd.cpp | 2 +- examples/common/entry/entry.cpp | 13 +++++++++++++ examples/common/entry/entry.h | 14 -------------- examples/common/entry/entry_p.h | 8 ++++++++ 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/examples/common/entry/cmd.cpp b/examples/common/entry/cmd.cpp index bbe5a9a64..b31642dcc 100644 --- a/examples/common/entry/cmd.cpp +++ b/examples/common/entry/cmd.cpp @@ -12,7 +12,7 @@ #include "dbg.h" #include "cmd.h" -#include "entry.h" //TinyStlCustomAllocator +#include "entry_p.h" #include #include diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index 3b4a49410..06ac35109 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -451,6 +451,19 @@ namespace entry return &s_allocator; } + void* TinyStlAllocator::static_allocate(size_t _bytes) + { + return BX_ALLOC(getAllocator(), _bytes); + } + + void TinyStlAllocator::static_deallocate(void* _ptr, size_t /*_bytes*/) + { + if (NULL != _ptr) + { + BX_FREE(getAllocator(), _ptr); + } + } + } // namespace entry extern "C" bool entry_process_events(uint32_t* _width, uint32_t* _height, uint32_t* _debug, uint32_t* _reset) diff --git a/examples/common/entry/entry.h b/examples/common/entry/entry.h index 0c92440d4..7f6524b8a 100644 --- a/examples/common/entry/entry.h +++ b/examples/common/entry/entry.h @@ -18,20 +18,6 @@ extern "C" int _main_(int _argc, char** _argv); #define ENTRY_WINDOW_FLAG_ASPECT_RATIO UINT32_C(0x00000001) #define ENTRY_WINDOW_FLAG_FRAME UINT32_C(0x00000002) -// For a custom tinystl allocator, define this and implement TinyStlCustomAllocator somewhere in the project. -#ifndef ENTRY_CONFIG_USE_TINYSTL_CUSTOM_ALLOCATOR -# define ENTRY_CONFIG_USE_TINYSTL_CUSTOM_ALLOCATOR 0 -#endif // ENTRY_CONFIG_USE_TINYSTL - -#if ENTRY_CONFIG_USE_TINYSTL_CUSTOM_ALLOCATOR - struct TinyStlCustomAllocator - { - static void* static_allocate(size_t _bytes); - static void static_deallocate(void* _ptr, size_t /*_bytes*/); - }; -# define TINYSTL_ALLOCATOR TinyStlCustomAllocator -#endif //ENTRY_CONFIG_USE_TINYSTL_CUSTOM_ALLOCATOR - namespace entry { struct WindowHandle { uint16_t idx; }; diff --git a/examples/common/entry/entry_p.h b/examples/common/entry/entry_p.h index 09fa203bd..379e250fd 100644 --- a/examples/common/entry/entry_p.h +++ b/examples/common/entry/entry_p.h @@ -6,6 +6,8 @@ #ifndef ENTRY_PRIVATE_H_HEADER_GUARD #define ENTRY_PRIVATE_H_HEADER_GUARD +#define TINYSTL_ALLOCATOR entry::TinyStlAllocator + #include #include "entry.h" @@ -42,6 +44,12 @@ namespace entry { + struct TinyStlAllocator + { + static void* static_allocate(size_t _bytes); + static void static_deallocate(void* _ptr, size_t /*_bytes*/); + }; + int main(int _argc, char** _argv); struct Event