mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Let mem_rmalloc call mem_malloc instead of std::malloc
`mem_rmalloc` should use `mem_malloc` instead of `std::malloc` to match the `mem_free` deallocation call.
This commit is contained in:
parent
48c87750f4
commit
15095f8763
23
mem/mem.h
23
mem/mem.h
@ -76,17 +76,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
template<typename T> static inline T *mem_rmalloc()
|
|
||||||
{
|
|
||||||
static_assert(std::is_trivially_constructible_v<T> && std::is_trivially_destructible_v<T>);
|
|
||||||
return static_cast<T *>(std::malloc(sizeof(T)));
|
|
||||||
}
|
|
||||||
template<typename T> static inline T *mem_rmalloc(std::size_t nelem)
|
|
||||||
{
|
|
||||||
static_assert(std::is_trivially_constructible_v<T> && std::is_trivially_destructible_v<T>);
|
|
||||||
return static_cast<T *>(std::malloc(nelem * sizeof(T)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Memory management debugging
|
// Memory management debugging
|
||||||
#ifdef MEM_USE_RTL
|
#ifdef MEM_USE_RTL
|
||||||
#define mem_malloc(d) malloc(d) // Use this if your going to run BoundsChecker
|
#define mem_malloc(d) malloc(d) // Use this if your going to run BoundsChecker
|
||||||
@ -137,4 +126,16 @@ bool mem_dumpmallocstofile(char *filename);
|
|||||||
|
|
||||||
void mem_heapcheck();
|
void mem_heapcheck();
|
||||||
|
|
||||||
|
// type aware memory allocation
|
||||||
|
template<typename T> static inline T *mem_rmalloc()
|
||||||
|
{
|
||||||
|
static_assert(std::is_trivially_constructible_v<T> && std::is_trivially_destructible_v<T>);
|
||||||
|
return static_cast<T *>(mem_malloc(sizeof(T)));
|
||||||
|
}
|
||||||
|
template<typename T> static inline T *mem_rmalloc(std::size_t nelem)
|
||||||
|
{
|
||||||
|
static_assert(std::is_trivially_constructible_v<T> && std::is_trivially_destructible_v<T>);
|
||||||
|
return static_cast<T *>(mem_malloc(nelem * sizeof(T)));
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user