CThreadSafeMemoryPool::Alloc
0x0008bed0 · 549 bytes · __cdecl
_ZN21CThreadSafeMemoryPool5AllocEj
Decompiled
undefined (1 param)
/* CThreadSafeMemoryPool::Alloc(unsigned int) */
undefined4 * CThreadSafeMemoryPool::Alloc(uint param_1)
{
uint uVar1;
undefined4 *puVar2;
undefined4 uVar3;
char cVar4;
int iVar5;
undefined4 *puVar6;
undefined4 *puVar7;
uint uVar8;
int local_40;
int local_38;
undefined4 *local_24;
int local_20;
local_40 = 999;
uVar1 = param_1 + 0x18;
do {
CThreadSpinRWLock::LockForRead();
puVar6 = *(undefined4 **)(param_1 + 0x3c);
iVar5 = puVar6[1];
puVar7 = (undefined4 *)*puVar6;
while (puVar7 != (undefined4 *)0x0) {
cVar4 = ThreadInterlockedAssignIf64(puVar6,*puVar7,iVar5 + -1,puVar7,iVar5);
if (cVar4 != '\0') {
CThreadSpinRWLock::UnlockRead();
LOCK();
*(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;
UNLOCK();
return puVar7;
}
iVar5 = puVar6[1];
puVar7 = (undefined4 *)*puVar6;
}
uVar8 = uVar1;
CThreadSpinRWLock::UnlockRead();
iVar5 = ThreadGetCurrentId(uVar8);
LOCK();
*(int *)(param_1 + 0x20) = *(int *)(param_1 + 0x20) + 1;
UNLOCK();
if ((0 < *(int *)(param_1 + 0x1c)) ||
(((*(int *)(param_1 + 0x18) != 0 && (iVar5 != *(int *)(param_1 + 0x18))) ||
(cVar4 = ThreadInterlockedAssignIf64(uVar1,iVar5,0,0,0), cVar4 == '\0')))) {
CThreadSpinRWLock::SpinLockForWrite(uVar1);
}
if (*(short *)(*(int *)(param_1 + 0x3c) + 4) < 1) {
local_38 = *(int *)(param_1 + 8) * *(int *)(param_1 + 4);
if (*(int *)param_1 == 1) {
local_38 = (*(int *)(param_1 + 0x34) + 1) * local_38;
}
else if ((*(int *)param_1 == 0) && (*(int *)(param_1 + 0x34) == 1)) goto LAB_0008c0e8;
puVar6 = (undefined4 *)memalign(8,local_38);
if (puVar6 == (undefined4 *)0x0) {
LAB_0008c0e8:
CThreadSpinRWLock::UnlockWrite();
return (undefined4 *)0x0;
}
for (puVar7 = puVar6; puVar7 < (undefined4 *)(local_38 + (int)puVar6);
puVar7 = (undefined4 *)((int)puVar7 + *(int *)(param_1 + 4))) {
puVar2 = *(undefined4 **)(param_1 + 0x3c);
do {
iVar5 = puVar2[1];
uVar3 = *puVar2;
*puVar7 = uVar3;
/* try { // try from 0008c024 to 0008c05c has its CatchHandler @ 0008c0fd */
cVar4 = ThreadInterlockedAssignIf64(puVar2,puVar7,iVar5 + 0x10001,uVar3,iVar5);
} while (cVar4 == '\0');
}
*(int *)(param_1 + 0x10) = *(int *)(param_1 + 0x10) + local_38;
local_20 = local_38;
local_24 = puVar6;
CUtlVector<CThreadSafeMemoryPool::BlockSet_t,CUtlMemory<CThreadSafeMemoryPool::BlockSet_t,int>>
::InsertBefore((CUtlVector<CThreadSafeMemoryPool::BlockSet_t,CUtlMemory<CThreadSafeMemoryPool::BlockSet_t,int>>
*)(param_1 + 0x28),*(int *)(param_1 + 0x34),(BlockSet_t *)&local_24);
CThreadSpinRWLock::UnlockWrite();
}
else {
CThreadSpinRWLock::UnlockWrite();
}
local_40 = local_40 + -1;
if (local_40 == 0) {
return (undefined4 *)0x0;
}
} while( true );
}
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.