This commit is contained in:
Branimir Karadžić
2015-02-08 10:25:53 -08:00
parent 65bb50f84a
commit 6d2d04cad5
4 changed files with 22 additions and 15 deletions

View File

@@ -12,7 +12,7 @@
#include "dbg.h"
#include "cmd.h"
#include "entry.h" //TinyStlCustomAllocator
#include "entry_p.h"
#include <tinystl/allocator.h>
#include <tinystl/string.h>

View File

@@ -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)

View File

@@ -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; };

View File

@@ -6,6 +6,8 @@
#ifndef ENTRY_PRIVATE_H_HEADER_GUARD
#define ENTRY_PRIVATE_H_HEADER_GUARD
#define TINYSTL_ALLOCATOR entry::TinyStlAllocator
#include <bx/spscqueue.h>
#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