summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/07-callback/callback.cpp
diff options
context:
space:
mode:
author Branimir Karadzic <branimirkaradzic@gmail.com>2016-01-04 19:00:51 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2016-01-04 19:00:51 +0100
commitfc07cc3621be84d6b54b9a02f946ca9e33272758 (patch)
tree8e906945079bd6b41eb6051a2b71f0f196c06c04 /3rdparty/bgfx/examples/07-callback/callback.cpp
parent3f4fe77c75571ff17436909c3e579da27b646368 (diff)
Added latest BX and BGFX (nw)
Diffstat (limited to '3rdparty/bgfx/examples/07-callback/callback.cpp')
-rw-r--r--3rdparty/bgfx/examples/07-callback/callback.cpp55
1 files changed, 28 insertions, 27 deletions
diff --git a/3rdparty/bgfx/examples/07-callback/callback.cpp b/3rdparty/bgfx/examples/07-callback/callback.cpp
index 0def881acdc..cdc1b6b5b5a 100644
--- a/3rdparty/bgfx/examples/07-callback/callback.cpp
+++ b/3rdparty/bgfx/examples/07-callback/callback.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright 2011-2015 Branimir Karadzic. All rights reserved.
- * License: http://www.opensource.org/licenses/BSD-2-Clause
+ * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "common.h"
@@ -291,7 +291,7 @@ struct BgfxCallback : public bgfx::CallbackI
AviWriter* m_writer;
};
-class BgfxAllocator : public bx::ReallocatorI
+class BgfxAllocator : public bx::AllocatorI
{
public:
BgfxAllocator()
@@ -304,39 +304,40 @@ public:
{
}
- virtual void* alloc(size_t _size, size_t _align, const char* _file, uint32_t _line) BX_OVERRIDE
+ virtual void* realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line) BX_OVERRIDE
{
- if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
+ if (0 == _size)
{
- void* ptr = ::malloc(_size);
- dbgPrintf("%s(%d): ALLOC %p of %d byte(s)\n", _file, _line, ptr, _size);
- ++m_numBlocks;
- m_maxBlocks = bx::uint32_max(m_maxBlocks, m_numBlocks);
- return ptr;
- }
-
- return bx::alignedAlloc(this, _size, _align, _file, _line);
- }
+ if (NULL != _ptr)
+ {
+ if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
+ {
+ dbgPrintf("%s(%d): FREE %p\n", _file, _line, _ptr);
+ ::free(_ptr);
+ --m_numBlocks;
+ }
+ else
+ {
+ bx::alignedFree(this, _ptr, _align, _file, _line);
+ }
+ }
- virtual void free(void* _ptr, size_t _align, const char* _file, uint32_t _line) BX_OVERRIDE
- {
- if (NULL != _ptr)
+ return NULL;
+ }
+ else if (NULL == _ptr)
{
if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
{
- dbgPrintf("%s(%d): FREE %p\n", _file, _line, _ptr);
- ::free(_ptr);
- --m_numBlocks;
- }
- else
- {
- bx::alignedFree(this, _ptr, _align, _file, _line);
+ void* ptr = ::malloc(_size);
+ dbgPrintf("%s(%d): ALLOC %p of %d byte(s)\n", _file, _line, ptr, _size);
+ ++m_numBlocks;
+ m_maxBlocks = bx::uint32_max(m_maxBlocks, m_numBlocks);
+ return ptr;
}
+
+ return bx::alignedAlloc(this, _size, _align, _file, _line);
}
- }
- virtual void* realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line) BX_OVERRIDE
- {
if (BX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT >= _align)
{
void* ptr = ::realloc(_ptr, _size);