Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Jun 11, 2017
1 parent c964cd4 commit 6d35b12
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 30 deletions.
4 changes: 0 additions & 4 deletions include/bx/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
19 changes: 5 additions & 14 deletions include/bx/crtimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
14 changes: 5 additions & 9 deletions src/crtimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@
*/

#include <bx/crtimpl.h>
#include <stdio.h>

#if BX_CONFIG_ALLOCATOR_CRT
# include <malloc.h>
#endif // BX_CONFIG_ALLOCATOR_CRT
#include <stdio.h>
#include <malloc.h>

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)
{
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/simd_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/string_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tools/bin2c/bin2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 6d35b12

Please sign in to comment.