diff --git a/LICENSE b/LICENSE index fd7fbc221..1d7f50bef 100644 --- a/LICENSE +++ b/LICENSE @@ -20,3 +20,5 @@ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +https://github.com/bkaradzic/bgfx diff --git a/examples/07-callback/callback.cpp b/examples/07-callback/callback.cpp index 75e94795c..2739113dc 100644 --- a/examples/07-callback/callback.cpp +++ b/examples/07-callback/callback.cpp @@ -337,10 +337,13 @@ public: virtual void free(void* _ptr, const char* _file, uint32_t _line) BX_OVERRIDE { - dbgPrintf("%s(%d): FREE %p\n", _file, _line, _ptr); - BX_UNUSED(_file, _line); - ::free(_ptr); - --m_numBlocks; + if (NULL != _ptr) + { + dbgPrintf("%s(%d): FREE %p\n", _file, _line, _ptr); + BX_UNUSED(_file, _line); + ::free(_ptr); + --m_numBlocks; + } } virtual void* realloc(void* _ptr, size_t _size, const char* _file, uint32_t _line) BX_OVERRIDE diff --git a/examples/common/font/font_manager.cpp b/examples/common/font/font_manager.cpp index 3156e2ee0..cb6c536ad 100644 --- a/examples/common/font/font_manager.cpp +++ b/examples/common/font/font_manager.cpp @@ -13,21 +13,8 @@ #include "font_manager.h" #include "../cube_atlas.h" -#if BGFX_CONFIG_USE_TINYSTL -namespace tinystl -{ -} // namespace tinystl -# include +#include namespace stl = tinystl; -#else -# include -namespace std { namespace tr1 {} } -namespace stl -{ - using namespace std; - using namespace std::tr1; -} -#endif // BGFX_CONFIG_USE_TINYSTL struct FTHolder { diff --git a/makefile b/makefile index 3bb471ff3..dfc79790f 100644 --- a/makefile +++ b/makefile @@ -17,7 +17,6 @@ all: premake4 --file=premake/premake4.lua --gcc=ios-simulator gmake premake4 --file=premake/premake4.lua --gcc=qnx-arm gmake premake4 --file=premake/premake4.lua xcode4 - make -s --no-print-directory -C src android-arm-debug: make -R -C .build/projects/gmake-android-arm config=debug diff --git a/premake/bgfx.lua b/premake/bgfx.lua index 0a009c531..2bd25728d 100644 --- a/premake/bgfx.lua +++ b/premake/bgfx.lua @@ -8,7 +8,6 @@ project "bgfx" kind "StaticLib" includedirs { - BGFX_DIR .. "../tinystl/include", BGFX_DIR .. "../bx/include", } diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 5c3fb2696..5d88da01b 100755 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -5,22 +5,6 @@ #include "bgfx_p.h" -#if BGFX_CONFIG_USE_TINYSTL -namespace tinystl -{ - void* bgfx_allocator::static_allocate(size_t _bytes) - { - return BX_ALLOC(g_allocator, _bytes); - } - - void bgfx_allocator::static_deallocate(void* _ptr, size_t /*_bytes*/) - { - BX_FREE(g_allocator, _ptr); - } - -} // namespace tinystl -#endif // BGFX_CONFIG_USE_TINYSTL - namespace bgfx { #define BGFX_MAIN_THREAD_MAGIC 0x78666762 @@ -62,6 +46,16 @@ namespace bgfx } #endif // BX_PLATFORM_* + void* TinyStlAllocator::static_allocate(size_t _bytes) + { + return BX_ALLOC(bgfx::g_allocator, _bytes); + } + + void TinyStlAllocator::static_deallocate(void* _ptr, size_t /*_bytes*/) + { + BX_FREE(bgfx::g_allocator, _ptr); + } + struct CallbackStub : public CallbackI { virtual ~CallbackStub() @@ -134,12 +128,13 @@ namespace bgfx virtual void free(void* _ptr, const char* _file, uint32_t _line) BX_OVERRIDE { - BX_CHECK(_ptr != NULL, "Freeing NULL! Fix it!"); + if (NULL != _ptr) + { + --m_numBlocks; - --m_numBlocks; - - BX_UNUSED(_file, _line); - ::free(_ptr); + BX_UNUSED(_file, _line); + ::free(_ptr); + } } virtual void* realloc(void* _ptr, size_t _size, const char* _file, uint32_t _line) BX_OVERRIDE diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 7f0ca373c..c65ab4564 100755 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -82,19 +82,18 @@ namespace bgfx #include // mingw wants it to be before tr1/unordered_*... #if BGFX_CONFIG_USE_TINYSTL -namespace tinystl +namespace bgfx { - struct bgfx_allocator + struct TinyStlAllocator { static void* static_allocate(size_t _bytes); static void static_deallocate(void* _ptr, size_t /*_bytes*/); }; -} // namespace tinystl -# define TINYSTL_ALLOCATOR tinystl::bgfx_allocator - -# include -# include -# include +} // namespace bgfx +# define TINYSTL_ALLOCATOR bgfx::TinyStlAllocator +# include +# include +# include namespace stl = tinystl; #else # include diff --git a/src/config.h b/src/config.h index c6a88433d..359952806 100644 --- a/src/config.h +++ b/src/config.h @@ -212,7 +212,7 @@ #endif // BGFX_CONFIG_MAX_CONSTANT_BUFFER_SIZE #ifndef BGFX_CONFIG_USE_TINYSTL -# define BGFX_CONFIG_USE_TINYSTL 0 +# define BGFX_CONFIG_USE_TINYSTL 1 #endif // BGFX_CONFIG_USE_TINYSTL #ifndef BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT