Custom allocator test.

This commit is contained in:
Bartosz Taudul 2020-09-22 18:22:53 +02:00
parent 4db092437c
commit 4537276e98
1 changed files with 23 additions and 0 deletions

View File

@ -33,6 +33,19 @@ void operator delete( void* ptr ) noexcept
free( ptr );
}
void* CustomAlloc( size_t count )
{
auto ptr = malloc( count );
TracyAllocNS( ptr, count, 10, "Custom alloc" );
return ptr;
}
void CustomFree( void* ptr )
{
TracyFreeNS( ptr, 10, "Custom alloc" );
free( ptr );
}
void TestFunction()
{
tracy::SetThreadName( "First/second thread" );
@ -254,6 +267,16 @@ void OnlyMemory()
{
tracy::SetThreadName( "Only memory" );
new int;
void* ptrs[16];
for( int i=1; i<16; i++ )
{
ptrs[i] = CustomAlloc( i * 1024 );
}
for( int i=1; i<16; i++ )
{
CustomFree( ptrs[i] );
}
}
static TracyLockable( std::mutex, deadlockMutex1 );