//
// std::vector>::_M_default_append from 0x36f20c to 0x36f2bc (176 bytes)
//
// 2 xrefs:
// > LevelEditorLayer::createObjectsFromSetup @ 0x370e90
// > LevelEditorLayer::createObjectsFromString @ 0x371120
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void __fastcall std::vector::_M_default_append(int a1, unsigned int a2)
{
_DWORD *v4; // r3
unsigned int v5; // r2
unsigned int v6; // r3
unsigned int v7; // r4
char *v8; // r8
size_t v9; // r6
char *v10; // r6
unsigned int v11; // r3
char *v12; // r2
char *v13; // r6
if ( !a2 )
return;
v4 = *(_DWORD **)(a1 + 4);
if ( a2 <= (*(_DWORD *)(a1 + 8) - (int)v4) >> 2 )
{
v5 = a2;
do
{
--v5;
*v4++ = 0;
}
while ( v5 );
*(_DWORD *)(a1 + 4) += 4 * a2;
return;
}
v6 = ((int)v4 - *(_DWORD *)a1) >> 2;
if ( 0x3FFFFFFF - v6 < a2 )
sub_7731C4("vector::_M_default_append", a2, 0x3FFFFFFF - v6);
if ( v6 < a2 )
v7 = v6 + a2;
else
v7 = 2 * v6;
if ( v7 >= v6 && v7 < 0x40000000 )
{
if ( !v7 )
{
v8 = nullptr;
goto LABEL_15;
}
}
else
{
v7 = 0x3FFFFFFF;
}
v8 = (char *)operator new(4 * v7);
LABEL_15:
v9 = *(_DWORD *)(a1 + 4) - *(_DWORD *)a1;
if ( v9 >> 2 )
memmove(v8, *(const void **)a1, v9);
v10 = &v8[v9];
v11 = a2;
v12 = v10;
do
{
--v11;
*(_DWORD *)v12 = 0;
v12 += 4;
}
while ( v11 );
v13 = &v10[4 * a2];
if ( *(_DWORD *)a1 )
operator delete(*(void **)a1);
*(_DWORD *)a1 = v8;
*(_DWORD *)(a1 + 4) = v13;
*(_DWORD *)(a1 + 8) = &v8[4 * v7];
}