mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Added bx::Location, and removed allocator macros.
This commit is contained in:
@@ -21,7 +21,7 @@ namespace bx
|
||||
{
|
||||
}
|
||||
|
||||
void* DefaultAllocator::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* _filePath, uint32_t _line)
|
||||
{
|
||||
if (0 == _size)
|
||||
{
|
||||
@@ -34,7 +34,7 @@ namespace bx
|
||||
}
|
||||
|
||||
# if BX_COMPILER_MSVC
|
||||
BX_UNUSED(_file, _line);
|
||||
BX_UNUSED(_filePath, _line);
|
||||
_aligned_free(_ptr);
|
||||
# else
|
||||
alignedFree(this, _ptr, _align, _file, _line);
|
||||
@@ -51,7 +51,7 @@ namespace bx
|
||||
}
|
||||
|
||||
# if BX_COMPILER_MSVC
|
||||
BX_UNUSED(_file, _line);
|
||||
BX_UNUSED(_filePath, _line);
|
||||
return _aligned_malloc(_size, _align);
|
||||
# else
|
||||
return alignedAlloc(this, _size, _align, _file, _line);
|
||||
@@ -64,7 +64,7 @@ namespace bx
|
||||
}
|
||||
|
||||
# if BX_COMPILER_MSVC
|
||||
BX_UNUSED(_file, _line);
|
||||
BX_UNUSED(_filePath, _line);
|
||||
return _aligned_realloc(_ptr, _size, _align);
|
||||
# else
|
||||
return alignedRealloc(this, _ptr, _size, _align, _file, _line);
|
||||
|
||||
10
src/bx.cpp
10
src/bx.cpp
@@ -12,6 +12,16 @@
|
||||
|
||||
namespace bx
|
||||
{
|
||||
Location Location::current(const char* _filePath, uint32_t _line)
|
||||
{
|
||||
return Location(_filePath, _line);
|
||||
}
|
||||
|
||||
LocationFull LocationFull::current(const char* _function, const char* _filePath, uint32_t _line)
|
||||
{
|
||||
return LocationFull(_function, _filePath, _line);
|
||||
}
|
||||
|
||||
void swap(void* _a, void* _b, size_t _numBytes)
|
||||
{
|
||||
uint8_t* lhs = (uint8_t*)_a;
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
#define INI_MALLOC(_ctx, _size) (BX_ALLOC(reinterpret_cast<bx::AllocatorI*>(_ctx), _size) )
|
||||
#define INI_FREE(_ctx, _ptr) (BX_FREE(reinterpret_cast<bx::AllocatorI*>(_ctx), _ptr) )
|
||||
#define INI_MALLOC(_ctx, _size) (bx::alloc(reinterpret_cast<bx::AllocatorI*>(_ctx), _size) )
|
||||
#define INI_FREE(_ctx, _ptr) (bx::free(reinterpret_cast<bx::AllocatorI*>(_ctx), _ptr) )
|
||||
#define INI_MEMCPY(_dst, _src, _count) (bx::memCopy(_dst, _src, _count) )
|
||||
#define INI_STRLEN(_str) (bx::strLen(_str) )
|
||||
#define INI_STRNICMP(_s1, _s2, _len) (bx::strCmpI(_s1, _s2, _len) )
|
||||
@@ -170,12 +170,12 @@ int32_t Settings::read(ReaderSeekerI* _reader, Error* _err)
|
||||
{
|
||||
int32_t size = int32_t(getRemain(_reader) );
|
||||
|
||||
void* data = BX_ALLOC(m_allocator, size);
|
||||
void* data = bx::alloc(m_allocator, size);
|
||||
|
||||
int32_t total = bx::read(_reader, data, size, _err);
|
||||
load(data, size);
|
||||
|
||||
BX_FREE(m_allocator, data);
|
||||
bx::free(m_allocator, data);
|
||||
|
||||
return total;
|
||||
}
|
||||
@@ -185,12 +185,12 @@ int32_t Settings::write(WriterI* _writer, Error* _err) const
|
||||
ini_t* ini = INI_T(m_ini);
|
||||
|
||||
int32_t size = ini_save(ini, NULL, 0);
|
||||
void* data = BX_ALLOC(m_allocator, size);
|
||||
void* data = bx::alloc(m_allocator, size);
|
||||
|
||||
ini_save(ini, (char*)data, size);
|
||||
int32_t total = bx::write(_writer, data, size-1, _err);
|
||||
|
||||
BX_FREE(m_allocator, data);
|
||||
bx::free(m_allocator, data);
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user