tracy/common/TracyAlloc.hpp

70 lines
1.0 KiB
C++
Raw Normal View History

2017-10-14 14:52:05 +00:00
#ifndef __TRACYALLOC_HPP__
#define __TRACYALLOC_HPP__
2019-11-15 19:17:55 +00:00
#include <stdlib.h>
2017-10-14 14:52:05 +00:00
#ifdef TRACY_ENABLE
# include "TracyApi.h"
# include "TracyForceInline.hpp"
# include "../client/tracy_rpmalloc.hpp"
#endif
2017-10-14 14:52:05 +00:00
namespace tracy
{
#ifdef TRACY_ENABLE
TRACY_API void InitRpmalloc();
#endif
2017-10-14 14:52:05 +00:00
static inline void* tracy_malloc( size_t size )
{
#ifdef TRACY_ENABLE
InitRpmalloc();
2017-10-14 14:52:05 +00:00
return rpmalloc( size );
#else
return malloc( size );
#endif
2017-10-14 14:52:05 +00:00
}
static inline void* tracy_malloc_fast( size_t size )
{
#ifdef TRACY_ENABLE
return rpmalloc( size );
#else
return malloc( size );
#endif
}
2017-10-14 14:52:05 +00:00
static inline void tracy_free( void* ptr )
{
#ifdef TRACY_ENABLE
InitRpmalloc();
2017-10-14 14:52:05 +00:00
rpfree( ptr );
#else
free( ptr );
#endif
2017-10-14 14:52:05 +00:00
}
static inline void tracy_free_fast( void* ptr )
{
#ifdef TRACY_ENABLE
rpfree( ptr );
#else
free( ptr );
#endif
}
2020-10-22 20:24:32 +00:00
static inline void* tracy_realloc( void* ptr, size_t size )
{
#ifdef TRACY_ENABLE
InitRpmalloc();
2020-10-22 20:24:32 +00:00
return rprealloc( ptr, size );
#else
return realloc( ptr, size );
#endif
}
2017-10-14 14:52:05 +00:00
}
#endif