mirror of
https://github.com/wolfpld/tracy.git
synced 2024-12-01 17:34:36 +00:00
58 lines
931 B
C++
58 lines
931 B
C++
#ifndef __TRACYALLOC_HPP__
|
|
#define __TRACYALLOC_HPP__
|
|
|
|
#include <stdlib.h>
|
|
|
|
#ifdef TRACY_ENABLE
|
|
# include "TracyApi.h"
|
|
# include "TracyForceInline.hpp"
|
|
# include "../client/tracy_rpmalloc.hpp"
|
|
#endif
|
|
|
|
namespace tracy
|
|
{
|
|
|
|
#ifdef TRACY_ENABLE
|
|
extern thread_local bool RpThreadInitDone;
|
|
TRACY_API void InitRpmallocPlumbing();
|
|
|
|
static tracy_force_inline void InitRpmalloc()
|
|
{
|
|
if( !RpThreadInitDone ) InitRpmallocPlumbing();
|
|
}
|
|
#endif
|
|
|
|
static inline void* tracy_malloc( size_t size )
|
|
{
|
|
#ifdef TRACY_ENABLE
|
|
InitRpmalloc();
|
|
return rpmalloc( size );
|
|
#else
|
|
return malloc( size );
|
|
#endif
|
|
}
|
|
|
|
static inline void tracy_free( void* ptr )
|
|
{
|
|
#ifdef TRACY_ENABLE
|
|
InitRpmalloc();
|
|
rpfree( ptr );
|
|
#else
|
|
free( ptr );
|
|
#endif
|
|
}
|
|
|
|
static inline void* tracy_realloc( void* ptr, size_t size )
|
|
{
|
|
#ifdef TRACY_ENABLE
|
|
InitRpmalloc();
|
|
return rprealloc( ptr, size );
|
|
#else
|
|
return realloc( ptr, size );
|
|
#endif
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|