mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Add KeyValue leak tracing
CUtlVector has to be rebuild for this to work
This commit is contained in:
parent
c8432acc9a
commit
dc9798d455
62
r5dev/vpc/kvleaktrace.h
Normal file
62
r5dev/vpc/kvleaktrace.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef KVLEAKTRACE_H
|
||||
#define KVLEAKTRACE_H
|
||||
#include "tier1/utlvector.h"
|
||||
|
||||
#ifdef LEAKTRACK
|
||||
class CLeakTrack
|
||||
{
|
||||
public:
|
||||
CLeakTrack()
|
||||
{
|
||||
}
|
||||
~CLeakTrack()
|
||||
{
|
||||
if (keys.Count() != 0)
|
||||
{
|
||||
Assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
struct kve
|
||||
{
|
||||
KeyValues* kv;
|
||||
char name[256];
|
||||
};
|
||||
|
||||
void AddKv(KeyValues* kv, char const* name)
|
||||
{
|
||||
kve k;
|
||||
strncpy(k.name, name ? name : "NULL", sizeof(k.name));
|
||||
k.kv = kv;
|
||||
|
||||
keys.AddToTail(k);
|
||||
}
|
||||
|
||||
void RemoveKv(KeyValues* kv)
|
||||
{
|
||||
int c = keys.Count();
|
||||
for (int i = 0; i < c; i++)
|
||||
{
|
||||
if (keys[i].kv == kv)
|
||||
{
|
||||
keys.Remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CUtlVector< kve > keys;
|
||||
};
|
||||
|
||||
static CLeakTrack track;
|
||||
|
||||
#define TRACK_KV_ADD( ptr, name ) track.AddKv( ptr, name )
|
||||
#define TRACK_KV_REMOVE( ptr ) track.RemoveKv( ptr )
|
||||
|
||||
#else
|
||||
|
||||
#define TRACK_KV_ADD( ptr, name )
|
||||
#define TRACK_KV_REMOVE( ptr )
|
||||
|
||||
#endif
|
||||
#endif // KVLEAKTRACE_H
|
@ -440,6 +440,7 @@
|
||||
<ClInclude Include="..\vpc\IAppSystem.h" />
|
||||
<ClInclude Include="..\vpc\interfaces.h" />
|
||||
<ClInclude Include="..\vpc\keyvalues.h" />
|
||||
<ClInclude Include="..\vpc\kvleaktrace.h" />
|
||||
<ClInclude Include="..\vphysics\QHull.h" />
|
||||
<ClInclude Include="..\vpklib\packedstore.h" />
|
||||
<ClInclude Include="..\vstdlib\callback.h" />
|
||||
|
@ -1499,6 +1499,9 @@
|
||||
<ClInclude Include="..\tier1\strtools.h">
|
||||
<Filter>sdk\tier1</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\vpc\kvleaktrace.h">
|
||||
<Filter>sdk\vpc</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
@ -423,6 +423,7 @@
|
||||
<ClInclude Include="..\vpc\IAppSystem.h" />
|
||||
<ClInclude Include="..\vpc\interfaces.h" />
|
||||
<ClInclude Include="..\vpc\keyvalues.h" />
|
||||
<ClInclude Include="..\vpc\kvleaktrace.h" />
|
||||
<ClInclude Include="..\vphysics\QHull.h" />
|
||||
<ClInclude Include="..\vpklib\packedstore.h" />
|
||||
<ClInclude Include="..\vstdlib\callback.h" />
|
||||
|
@ -1113,6 +1113,9 @@
|
||||
<ClInclude Include="..\tier1\strtools.h">
|
||||
<Filter>sdk\tier1</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\vpc\kvleaktrace.h">
|
||||
<Filter>sdk\vpc</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\common\opcodes.cpp">
|
||||
|
@ -458,6 +458,7 @@
|
||||
<ClInclude Include="..\vpc\IAppSystem.h" />
|
||||
<ClInclude Include="..\vpc\interfaces.h" />
|
||||
<ClInclude Include="..\vpc\keyvalues.h" />
|
||||
<ClInclude Include="..\vpc\kvleaktrace.h" />
|
||||
<ClInclude Include="..\vphysics\QHull.h" />
|
||||
<ClInclude Include="..\vpklib\packedstore.h" />
|
||||
<ClInclude Include="..\vstdlib\callback.h" />
|
||||
|
@ -1562,6 +1562,9 @@
|
||||
<ClInclude Include="..\tier0\commonmacros.h">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\vpc\kvleaktrace.h">
|
||||
<Filter>sdk\vpc</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
Loading…
x
Reference in New Issue
Block a user