2017-10-14 14:52:05 +00:00
|
|
|
#ifndef __TRACYALLOC_HPP__
|
|
|
|
#define __TRACYALLOC_HPP__
|
2018-06-30 13:36:06 +00:00
|
|
|
|
2019-11-15 19:17:55 +00:00
|
|
|
#include <stdlib.h>
|
2017-10-14 14:52:05 +00:00
|
|
|
|
2022-08-08 17:30:00 +00:00
|
|
|
#if defined TRACY_ENABLE && !defined __EMSCRIPTEN__
|
2021-05-31 20:38:22 +00:00
|
|
|
# include "TracyApi.h"
|
2021-05-31 00:30:59 +00:00
|
|
|
# include "TracyForceInline.hpp"
|
2017-10-18 17:08:19 +00:00
|
|
|
# include "../client/tracy_rpmalloc.hpp"
|
2022-08-08 17:29:18 +00:00
|
|
|
# define TRACY_USE_RPMALLOC
|
2017-10-18 17:08:19 +00:00
|
|
|
#endif
|
2017-10-14 14:52:05 +00:00
|
|
|
|
|
|
|
namespace tracy
|
|
|
|
{
|
|
|
|
|
2022-08-08 17:29:18 +00:00
|
|
|
#ifdef TRACY_USE_RPMALLOC
|
2021-06-13 10:15:36 +00:00
|
|
|
TRACY_API void InitRpmalloc();
|
2022-08-08 17:29:18 +00:00
|
|
|
#else
|
|
|
|
static inline void InitRpmalloc() {}
|
2021-05-31 00:30:59 +00:00
|
|
|
#endif
|
|
|
|
|
2017-10-14 14:52:05 +00:00
|
|
|
static inline void* tracy_malloc( size_t size )
|
|
|
|
{
|
2022-08-08 17:29:18 +00:00
|
|
|
#ifdef TRACY_USE_RPMALLOC
|
2021-05-31 00:30:59 +00:00
|
|
|
InitRpmalloc();
|
2017-10-14 14:52:05 +00:00
|
|
|
return rpmalloc( size );
|
2017-10-18 17:08:19 +00:00
|
|
|
#else
|
|
|
|
return malloc( size );
|
|
|
|
#endif
|
2017-10-14 14:52:05 +00:00
|
|
|
}
|
|
|
|
|
2021-06-09 23:18:03 +00:00
|
|
|
static inline void* tracy_malloc_fast( size_t size )
|
|
|
|
{
|
2022-08-08 17:29:18 +00:00
|
|
|
#ifdef TRACY_USE_RPMALLOC
|
2021-06-09 23:18:03 +00:00
|
|
|
return rpmalloc( size );
|
|
|
|
#else
|
|
|
|
return malloc( size );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-10-14 14:52:05 +00:00
|
|
|
static inline void tracy_free( void* ptr )
|
|
|
|
{
|
2022-08-08 17:29:18 +00:00
|
|
|
#ifdef TRACY_USE_RPMALLOC
|
2021-05-31 00:30:59 +00:00
|
|
|
InitRpmalloc();
|
2017-10-14 14:52:05 +00:00
|
|
|
rpfree( ptr );
|
2017-10-18 17:08:19 +00:00
|
|
|
#else
|
|
|
|
free( ptr );
|
|
|
|
#endif
|
2017-10-14 14:52:05 +00:00
|
|
|
}
|
|
|
|
|
2021-06-09 23:18:03 +00:00
|
|
|
static inline void tracy_free_fast( void* ptr )
|
|
|
|
{
|
2022-08-08 17:29:18 +00:00
|
|
|
#ifdef TRACY_USE_RPMALLOC
|
2021-06-09 23:18:03 +00:00
|
|
|
rpfree( ptr );
|
|
|
|
#else
|
|
|
|
free( ptr );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-10-22 20:24:32 +00:00
|
|
|
static inline void* tracy_realloc( void* ptr, size_t size )
|
|
|
|
{
|
2022-08-08 17:29:18 +00:00
|
|
|
#ifdef TRACY_USE_RPMALLOC
|
2021-05-31 00:30:59 +00:00
|
|
|
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
|