CThreadSafeMultiMemoryPool::ReAlloc
0x00075820 · 489 bytes · __thiscall
_ZN26CThreadSafeMultiMemoryPool7ReAllocEPvj
Decompiled
undefined (3 params)
/* CThreadSafeMultiMemoryPool::ReAlloc(void*, unsigned int) */
void * __thiscall
CThreadSafeMultiMemoryPool::ReAlloc(CThreadSafeMultiMemoryPool *this,void *param_1,uint param_2)
{
CThreadSafeMultiMemoryPool *pCVar1;
CUtlRBTree<CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::Node_t,unsigned_short,CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
*this_00;
uint uVar2;
ushort uVar3;
uint uVar4;
uint *puVar5;
uint *puVar6;
void *pvVar7;
int iVar8;
uint *local_34 [3];
uint *local_28;
uint *local_24;
uint local_20;
if (param_1 == (void *)0x0) {
uVar4 = 0xffffffff;
if (*(int *)(this + 0x14) == -1) goto LAB_00075846;
}
else {
uVar4 = *(uint *)((int)param_1 + -4);
if (param_2 <= uVar4) {
return param_1;
}
if (uVar4 <= *(uint *)(this + 0x14)) {
LAB_00075846:
if (*(uint *)(*(int *)(*(int *)(this + 0x18) + (uVar4 - 1 >> 5) * 4) + 4) < param_2) {
puVar6 = (uint *)Alloc(this,param_2);
if (puVar6 != (uint *)0x0) {
*(uint *)(this + 0x50) = *(int *)(this + 0x50) + uVar4;
pvVar7 = (void *)_V_memcpy(puVar6,param_1,uVar4);
Free(pvVar7);
return puVar6;
}
param_1 = (uint *)0x0;
}
else {
*(uint *)((int)param_1 + -4) = param_2;
}
return param_1;
}
}
pCVar1 = this + 0x48;
uVar4 = ThreadGetCurrentId();
if (uVar4 != *(uint *)(this + 0x48)) {
LOCK();
uVar2 = *(uint *)pCVar1;
if (uVar2 == 0) {
*(uint *)pCVar1 = uVar4;
}
UNLOCK();
if (uVar2 != 0) {
CThreadFastMutex::Lock((uint)pCVar1,uVar4);
goto LAB_000758ab;
}
}
*(int *)(this + 0x4c) = *(int *)(this + 0x4c) + 1;
LAB_000758ab:
this_00 = (CUtlRBTree<CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::Node_t,unsigned_short,CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
*)(this + 0x2c);
puVar6 = (uint *)((int)param_1 + -4);
local_34[0] = puVar6;
/* try { // try from 000758c3 to 0007592f has its CatchHandler @ 00075a29 */
uVar3 = CUtlRBTree<CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::Node_t,unsigned_short,CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
::Find(this_00,(Node_t *)local_34);
if (uVar3 == 0xffff) {
puVar5 = (uint *)0x0;
}
else {
puVar5 = realloc(puVar6,param_2 + 4);
if (puVar5 == (uint *)0x0) {
CUtlRBTree<CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::Node_t,unsigned_short,CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
::RemoveAt(this_00,uVar3);
puVar5 = (uint *)0x0;
}
else {
*puVar5 = param_2;
if (puVar5 == puVar6) {
iVar8 = (uint)uVar3 * 0x14;
*(uint **)(*(int *)(this + 0x30) + 0xc + iVar8) = puVar6;
*(uint *)(*(int *)(this + 0x30) + 0x10 + iVar8) = param_2;
}
else {
CUtlRBTree<CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::Node_t,unsigned_short,CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
::RemoveAt(this_00,uVar3);
local_20 = param_2;
local_28 = puVar5;
local_24 = puVar5;
CUtlRBTree<CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::Node_t,unsigned_short,CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<void*,CThreadSafeMultiMemoryPool::RawAllocation_t,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
::Insert(this_00,(Node_t *)&local_28);
}
puVar5 = puVar5 + 1;
}
}
*(int *)(this + 0x4c) = *(int *)(this + 0x4c) + -1;
if (*(int *)(this + 0x4c) != 0) {
return puVar5;
}
LOCK();
*(uint *)pCVar1 = 0;
UNLOCK();
return puVar5;
}
SourceMod gamedata
paste intoaddons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)
Just a Signatures{} block, ready to drop into a gamedata
file. Wire it up in your plugin however you like - SDKCall, DHooks,
raw memory ops, or anything else.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.