CThreadSafeMultiMemoryPool::Alloc
0x000755d0 · 233 bytes · __thiscall
_ZN26CThreadSafeMultiMemoryPool5AllocEj
Decompiled
undefined (2 params)
/* CThreadSafeMultiMemoryPool::Alloc(unsigned int) */
uint * __thiscall CThreadSafeMultiMemoryPool::Alloc(CThreadSafeMultiMemoryPool *this,uint param_1)
{
CThreadSafeMultiMemoryPool *pCVar1;
uint uVar2;
uint *puVar3;
uint uVar4;
uint *local_28;
uint *local_24;
uint local_20;
if (param_1 == 0) {
return (uint *)0x0;
}
if (param_1 <= *(uint *)(this + 0x14)) {
puVar3 = (uint *)CThreadSafeMemoryPool::Alloc
(**(uint **)(*(int *)(this + 0x18) + (param_1 - 1 >> 5) * 4));
*puVar3 = param_1;
return puVar3 + 1;
}
puVar3 = malloc(param_1 + 4);
if (puVar3 == (uint *)0x0) {
return (uint *)0x0;
}
*puVar3 = 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_0007562f;
}
}
*(int *)(this + 0x4c) = *(int *)(this + 0x4c) + 1;
LAB_0007562f:
local_20 = param_1;
local_28 = puVar3;
local_24 = puVar3;
/* try { // try from 00075645 to 00075649 has its CatchHandler @ 000756ca */
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((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),(Node_t *)&local_28);
*(int *)(this + 0x4c) = *(int *)(this + 0x4c) + -1;
if (*(int *)(this + 0x4c) == 0) {
LOCK();
*(uint *)pCVar1 = 0;
UNLOCK();
}
return puVar3 + 1;
}
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.