diff --git a/TracyC.h b/TracyC.h index 786e72af..762c3ae5 100644 --- a/TracyC.h +++ b/TracyC.h @@ -22,6 +22,9 @@ typedef const void* TracyCZoneCtx; #define TracyCZoneText(c,x,y) #define TracyCZoneName(c,x,y) +#define TracyCAlloc(x,y) +#define TracyCFree(x) + #else #ifndef TracyConcat @@ -71,6 +74,20 @@ void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size_t size ); #define TracyCZoneText( ctx, txt, size ) ___tracy_emit_zone_text( ctx, txt, size ); #define TracyCZoneName( ctx, txt, size ) ___tracy_emit_zone_name( ctx, txt, size ); + +void ___tracy_emit_memory_alloc( const void* ptr, size_t size ); +void ___tracy_emit_memory_alloc_callstack( const void* ptr, size_t size, int depth ); +void ___tracy_emit_memory_free( const void* ptr ); +void ___tracy_emit_memory_free_callstack( const void* ptr, int depth ); + +#if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK +# define TracyCAlloc( ptr, size ) ___tracy_emit_memory_alloc_callstack( ptr, size, TRACY_CALLSTACK ) +# define TracyCFree( ptr ) ___tracy_emit_memory_alloc_free_callstack( ptr, TRACY_CALLSTACK ) +#else +# define TracyCAlloc( ptr, size ) ___tracy_emit_memory_alloc( ptr, size ); +# define TracyCFree( ptr ) ___tracy_emit_memory_free( ptr ); +#endif + #endif #ifdef __cplusplus diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 4daa652d..2114233d 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -2244,6 +2244,26 @@ void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size_t size ) } } +void ___tracy_emit_memory_alloc( const void* ptr, size_t size ) +{ + tracy::Profiler::MemAlloc( ptr, size ); +} + +void ___tracy_emit_memory_alloc_callstack( const void* ptr, size_t size, int depth ) +{ + tracy::Profiler::MemAllocCallstack( ptr, size, depth ); +} + +void ___tracy_emit_memory_free( const void* ptr ) +{ + tracy::Profiler::MemFree( ptr ); +} + +void ___tracy_emit_memory_free_callstack( const void* ptr, int depth ) +{ + tracy::Profiler::MemFreeCallstack( ptr, depth ); +} + #ifdef __cplusplus } #endif