//
// cocos2d::CCTextureAtlas::resizeCapacity from 0xda4bfc to 0xda4de8 (492 bytes)
//
// 4 xrefs:
// > cocos2d::CCLabelAtlas::setString @ 0xd54e4c
// > cocos2d::CCParticleBatchNode::increaseAtlasCapacityTo @ 0xd72a58
// > cocos2d::CCSpriteBatchNode::increaseAtlasCapacity @ 0xd88bf4
// > ??> @ 0x9c0d0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:08:31 +0000
//
__int64 __fastcall cocos2d::CCTextureAtlas::resizeCapacity(cocos2d::CCTextureAtlas *this, unsigned int a2)
{
unsigned int v2; // w21
__int64 v3; // x19
unsigned int v5; // w1
void *v6; // x0
char *v7; // x0
void *v8; // x22
void *v9; // x0
char *v10; // x0
void *v11; // x23
unsigned int v12; // w2
void *v13; // x0
void *v14; // x0
size_t v16; // x19
void *v17; // x0
void *v18; // x0
v2 = *((_DWORD *)this + 20);
if ( v2 == a2 )
return 1;
v3 = a2;
v5 = *((_DWORD *)this + 19);
v6 = *((void **)this + 12);
*((_DWORD *)this + 20) = v3;
if ( (unsigned int)v3 <= v5 )
v5 = v3;
*((_DWORD *)this + 19) = v5;
if ( !v6 )
{
v18 = malloc(96LL * (unsigned int)v3);
v8 = v18;
if ( v18 )
memset(v18, 0, 96LL * (unsigned int)v3);
LABEL_7:
v9 = *((void **)this + 7);
if ( v9 )
goto LABEL_8;
LABEL_21:
v16 = 2LL * (unsigned int)(6 * v3);
v17 = malloc(v16);
v11 = v17;
if ( v17 )
{
memset(v17, 0, v16);
if ( !v8 )
goto LABEL_11;
goto LABEL_17;
}
LABEL_25:
if ( v8 )
free(v8);
goto LABEL_12;
}
v7 = (char *)realloc(v6, 96 * v3);
LODWORD(v3) = *((_DWORD *)this + 20);
v8 = v7;
if ( !v7 || v2 >= (unsigned int)v3 )
goto LABEL_7;
memset(&v7[96 * v2], 0, 96LL * ((unsigned int)v3 - v2));
LODWORD(v3) = *((_DWORD *)this + 20);
v9 = *((void **)this + 7);
if ( !v9 )
goto LABEL_21;
LABEL_8:
v10 = (char *)realloc(v9, 12LL * (unsigned int)v3);
v11 = v10;
if ( !v10 )
goto LABEL_25;
v12 = *((_DWORD *)this + 20);
if ( v2 < v12 )
{
memset(&v10[2 * v2], 0, 12LL * (v12 - v2));
if ( !v8 )
goto LABEL_11;
LABEL_17:
*((_QWORD *)this + 12) = v8;
*((_QWORD *)this + 7) = v11;
cocos2d::CCTextureAtlas::setupIndices((__int64)this);
cocos2d::CCTextureAtlas::mapBuffers(this);
*((_BYTE *)this + 72) = 1;
return 1;
}
if ( v8 )
goto LABEL_17;
LABEL_11:
free(v11);
LABEL_12:
v13 = *((void **)this + 12);
if ( v13 )
{
free(v13);
*((_QWORD *)this + 12) = 0;
}
v14 = *((void **)this + 7);
if ( v14 )
{
free(v14);
*((_QWORD *)this + 7) = 0;
}
*((_DWORD *)this + 19) = 0;
*((_DWORD *)this + 20) = 0;
return 0;
}