Implement memory allocation tracking for C API.

This commit is contained in:
Bartosz Taudul 2019-06-24 20:22:19 +02:00
parent 281477f7f9
commit ee99ce833c
2 changed files with 37 additions and 0 deletions

View File

@ -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

View File

@ -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