//
// cocos2d::CCTextureAtlas::resizeCapacity from 0xb336d8 to 0xb338c4 (492 bytes)
//
// 4 xrefs:
// > cocos2d::CCLabelAtlas::setString @ 0xae188c
// > cocos2d::CCParticleBatchNode::increaseAtlasCapacityTo @ 0xb024c0
// > cocos2d::CCSpriteBatchNode::increaseAtlasCapacity @ 0xb17714
// > ??> @ 0x744f0
//
// 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
//
bool cocos2d::CCTextureAtlas::resizeCapacity(cocos2d::CCTextureAtlas *a1, unsigned int a2)
{
unsigned int m_uCapacity; // w21
__int64 v3; // x19
unsigned int m_uTotalQuads; // w1
cocos2d::ccV3F_C4B_T2F_Quad *m_pQuads; // x0
cocos2d::ccV3F_C4B_T2F_Quad *v7; // x0
cocos2d::ccV3F_C4B_T2F_Quad *v8; // x22
GLushort *m_pIndices; // x0
GLushort *v10; // x0
GLushort *v11; // x23
unsigned int v12; // w2
cocos2d::ccV3F_C4B_T2F_Quad *v13; // x0
GLushort *v14; // x0
size_t v16; // x19
GLushort *v17; // x0
cocos2d::ccV3F_C4B_T2F_Quad *v18; // x0
m_uCapacity = a1->m_uCapacity;
if ( m_uCapacity == a2 )
return 1;
v3 = a2;
m_uTotalQuads = a1->m_uTotalQuads;
m_pQuads = a1->m_pQuads;
a1->m_uCapacity = v3;
if ( (unsigned int)v3 <= m_uTotalQuads )
m_uTotalQuads = v3;
a1->m_uTotalQuads = m_uTotalQuads;
if ( !m_pQuads )
{
v18 = (cocos2d::ccV3F_C4B_T2F_Quad *)malloc(96LL * (unsigned int)v3);
v8 = v18;
if ( v18 )
memset(v18, 0, 96LL * (unsigned int)v3);
LABEL_7:
m_pIndices = a1->m_pIndices;
if ( m_pIndices )
goto LABEL_8;
LABEL_21:
v16 = 2LL * (unsigned int)(6 * v3);
v17 = (GLushort *)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 = (cocos2d::ccV3F_C4B_T2F_Quad *)realloc(m_pQuads, 96 * v3);
LODWORD(v3) = a1->m_uCapacity;
v8 = v7;
if ( !v7 || m_uCapacity >= (unsigned int)v3 )
goto LABEL_7;
memset(&v7[m_uCapacity], 0, 96LL * ((unsigned int)v3 - m_uCapacity));
LODWORD(v3) = a1->m_uCapacity;
m_pIndices = a1->m_pIndices;
if ( !m_pIndices )
goto LABEL_21;
LABEL_8:
v10 = (GLushort *)realloc(m_pIndices, 12LL * (unsigned int)v3);
v11 = v10;
if ( !v10 )
goto LABEL_25;
v12 = a1->m_uCapacity;
if ( m_uCapacity < v12 )
{
memset(&v10[m_uCapacity], 0, 12LL * (v12 - m_uCapacity));
if ( !v8 )
goto LABEL_11;
LABEL_17:
a1->m_pQuads = v8;
a1->m_pIndices = v11;
cocos2d::CCTextureAtlas::setupIndices(a1);
cocos2d::CCTextureAtlas::mapBuffers(a1);
a1->m_bDirty = 1;
return 1;
}
if ( v8 )
goto LABEL_17;
LABEL_11:
free(v11);
LABEL_12:
v13 = a1->m_pQuads;
if ( v13 )
{
free(v13);
a1->m_pQuads = nullptr;
}
v14 = a1->m_pIndices;
if ( v14 )
{
free(v14);
a1->m_pIndices = nullptr;
}
a1->m_uTotalQuads = 0;
a1->m_uCapacity = 0;
return 0;
}