|
|
@@ -9,28 +9,8 @@
|
|
|
#include "bx.h"
|
|
|
#include "uint32_t.h"
|
|
|
|
|
|
-#if BX_CONFIG_ALLOCATOR_DEBUG
|
|
|
-# define BX_ALLOC(_allocator, _size) bx::alloc(_allocator, _size, 0, __FILE__, __LINE__)
|
|
|
-# define BX_REALLOC(_allocator, _ptr, _size) bx::realloc(_allocator, _ptr, _size, 0, __FILE__, __LINE__)
|
|
|
-# define BX_FREE(_allocator, _ptr) bx::free(_allocator, _ptr, 0, __FILE__, __LINE__)
|
|
|
-# define BX_ALIGNED_ALLOC(_allocator, _size, _align) bx::alloc(_allocator, _size, _align, __FILE__, __LINE__)
|
|
|
-# define BX_ALIGNED_REALLOC(_allocator, _ptr, _size, _align) bx::realloc(_allocator, _ptr, _size, _align, __FILE__, __LINE__)
|
|
|
-# define BX_ALIGNED_FREE(_allocator, _ptr, _align) bx::free(_allocator, _ptr, _align, __FILE__, __LINE__)
|
|
|
-# define BX_DELETE(_allocator, _ptr) bx::deleteObject(_allocator, _ptr, 0, __FILE__, __LINE__)
|
|
|
-# define BX_ALIGNED_DELETE(_allocator, _ptr, _align) bx::deleteObject(_allocator, _ptr, _align, __FILE__, __LINE__)
|
|
|
-#else
|
|
|
-# define BX_ALLOC(_allocator, _size) bx::alloc(_allocator, _size, 0)
|
|
|
-# define BX_REALLOC(_allocator, _ptr, _size) bx::realloc(_allocator, _ptr, _size, 0)
|
|
|
-# define BX_FREE(_allocator, _ptr) bx::free(_allocator, _ptr, 0)
|
|
|
-# define BX_ALIGNED_ALLOC(_allocator, _size, _align) bx::alloc(_allocator, _size, _align)
|
|
|
-# define BX_ALIGNED_REALLOC(_allocator, _ptr, _size, _align) bx::realloc(_allocator, _ptr, _size, _align)
|
|
|
-# define BX_ALIGNED_FREE(_allocator, _ptr, _align) bx::free(_allocator, _ptr, _align)
|
|
|
-# define BX_DELETE(_allocator, _ptr) bx::deleteObject(_allocator, _ptr, 0)
|
|
|
-# define BX_ALIGNED_DELETE(_allocator, _ptr, _align) bx::deleteObject(_allocator, _ptr, _align)
|
|
|
-#endif // BX_CONFIG_DEBUG_ALLOC
|
|
|
-
|
|
|
-#define BX_NEW(_allocator, _type) BX_PLACEMENT_NEW(BX_ALLOC(_allocator, sizeof(_type) ), _type)
|
|
|
-#define BX_ALIGNED_NEW(_allocator, _type, _align) BX_PLACEMENT_NEW(BX_ALIGNED_ALLOC(_allocator, sizeof(_type), _align), _type)
|
|
|
+#define BX_NEW(_allocator, _type) BX_PLACEMENT_NEW(bx::alloc(_allocator, sizeof(_type) ), _type)
|
|
|
+#define BX_ALIGNED_NEW(_allocator, _type, _align) BX_PLACEMENT_NEW(bx::alignedAlloc(_allocator, sizeof(_type), _align), _type)
|
|
|
#define BX_PLACEMENT_NEW(_ptr, _type) ::new(bx::PlacementNew, _ptr) _type
|
|
|
|
|
|
void* operator new(size_t, bx::PlacementNewTag, void* _ptr);
|
|
|
@@ -56,14 +36,14 @@ namespace bx
|
|
|
/// _size is not 0, memory block will be resized.
|
|
|
/// @param[in] _size If _ptr is set, and _size is 0, memory will be freed.
|
|
|
/// @param[in] _align Alignment.
|
|
|
- /// @param[in] _file Debug file path info.
|
|
|
+ /// @param[in] _filePath Debug file path info.
|
|
|
/// @param[in] _line Debug file line info.
|
|
|
///
|
|
|
virtual void* realloc(
|
|
|
void* _ptr
|
|
|
, size_t _size
|
|
|
, size_t _align
|
|
|
- , const char* _file
|
|
|
+ , const char* _filePath
|
|
|
, uint32_t _line
|
|
|
) = 0;
|
|
|
};
|
|
|
@@ -83,7 +63,7 @@ namespace bx
|
|
|
void* _ptr
|
|
|
, size_t _size
|
|
|
, size_t _align
|
|
|
- , const char* _file
|
|
|
+ , const char* _filePath
|
|
|
, uint32_t _line
|
|
|
) override;
|
|
|
};
|
|
|
@@ -100,8 +80,7 @@ namespace bx
|
|
|
AllocatorI* _allocator
|
|
|
, size_t _size
|
|
|
, size_t _align = 0
|
|
|
- , const char* _file = NULL
|
|
|
- , uint32_t _line = 0
|
|
|
+ , const Location& _location = Location::current()
|
|
|
);
|
|
|
|
|
|
/// Free memory.
|
|
|
@@ -109,8 +88,7 @@ namespace bx
|
|
|
AllocatorI* _allocator
|
|
|
, void* _ptr
|
|
|
, size_t _align = 0
|
|
|
- , const char* _file = NULL
|
|
|
- , uint32_t _line = 0
|
|
|
+ , const Location& _location = Location::current()
|
|
|
);
|
|
|
|
|
|
/// Resize memory block.
|
|
|
@@ -119,8 +97,7 @@ namespace bx
|
|
|
, void* _ptr
|
|
|
, size_t _size
|
|
|
, size_t _align = 0
|
|
|
- , const char* _file = NULL
|
|
|
- , uint32_t _line = 0
|
|
|
+ , const Location& _location = Location::current()
|
|
|
);
|
|
|
|
|
|
/// Allocate memory with specific alignment.
|
|
|
@@ -128,8 +105,7 @@ namespace bx
|
|
|
AllocatorI* _allocator
|
|
|
, size_t _size
|
|
|
, size_t _align
|
|
|
- , const char* _file = NULL
|
|
|
- , uint32_t _line = 0
|
|
|
+ , const Location& _location = Location::current()
|
|
|
);
|
|
|
|
|
|
/// Free memory that was allocated with aligned allocator.
|
|
|
@@ -137,8 +113,7 @@ namespace bx
|
|
|
AllocatorI* _allocator
|
|
|
, void* _ptr
|
|
|
, size_t /*_align*/
|
|
|
- , const char* _file = NULL
|
|
|
- , uint32_t _line = 0
|
|
|
+ , const Location& _location = Location::current()
|
|
|
);
|
|
|
|
|
|
/// Resize memory block that was allocated with aligned allocator.
|
|
|
@@ -147,8 +122,7 @@ namespace bx
|
|
|
, void* _ptr
|
|
|
, size_t _size
|
|
|
, size_t _align
|
|
|
- , const char* _file = NULL
|
|
|
- , uint32_t _line = 0
|
|
|
+ , const Location& _location = Location::current()
|
|
|
);
|
|
|
|
|
|
/// Delete object with specific allocator.
|
|
|
@@ -157,8 +131,7 @@ namespace bx
|
|
|
AllocatorI* _allocator
|
|
|
, ObjectT* _object
|
|
|
, size_t _align = 0
|
|
|
- , const char* _file = NULL
|
|
|
- , uint32_t _line = 0
|
|
|
+ , const Location& _location = Location::current()
|
|
|
);
|
|
|
|
|
|
} // namespace bx
|