//
// cocos2d::CCTextureAtlas::resizeCapacity from 0x10026a378 to 0x10026a4d4 (348 bytes)
//
// 2 xrefs:
// > cocos2d::CCSpriteBatchNode::increaseAtlasCapacity_1 @ 0x1001d7ce4
// > cocos2d::CCSpriteBatchNode::increaseAtlasCapacity @ 0x1001d7d30
//
// 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 __fastcall cocos2d::CCTextureAtlas::resizeCapacity(cocos2d::CCTextureAtlas *a1, unsigned int a2)
{
__int64 v2; // x22
unsigned int m_uCapacity; // w8
cocos2d::ccV3F_C4B_T2F_Quad *m_pQuads; // x0
size_t v7; // x1
cocos2d::ccV3F_C4B_T2F_Quad *v8; // x0
cocos2d::ccV3F_C4B_T2F_Quad *v9; // x20
unsigned int v10; // w8
GLushort *m_pIndices; // x0
__int64 v12; // x8
GLushort *v13; // x0
GLushort *v14; // x21
unsigned int v15; // w8
cocos2d::ccV3F_C4B_T2F_Quad *v16; // x0
GLushort *v17; // x0
v2 = *(&a1->m_uCapacity + 1);
if ( (_DWORD)v2 == a2 )
return 1;
m_uCapacity = a1->m_uCapacity;
if ( m_uCapacity >= a2 )
m_uCapacity = a2;
a1->m_uCapacity = m_uCapacity;
*(&a1->m_uCapacity + 1) = a2;
m_pQuads = a1->m_pQuads;
v7 = 96LL * a2;
if ( m_pQuads )
{
v8 = (cocos2d::ccV3F_C4B_T2F_Quad *)realloc(m_pQuads, v7);
v9 = v8;
if ( v8 )
{
v10 = *(&a1->m_uCapacity + 1);
if ( v10 > (unsigned int)v2 )
bzero(&v8[(unsigned int)v2], 96LL * (v10 - (unsigned int)v2));
}
}
else
{
v9 = (cocos2d::ccV3F_C4B_T2F_Quad *)calloc(1u, v7);
}
m_pIndices = a1->m_pIndices;
v12 = *(&a1->m_uCapacity + 1);
if ( m_pIndices )
{
v13 = (GLushort *)realloc(m_pIndices, 12 * v12);
if ( v13 )
{
v14 = v13;
v15 = *(&a1->m_uCapacity + 1);
if ( v15 > (unsigned int)v2 )
bzero(&v13[v2], 12LL * (v15 - (unsigned int)v2));
goto LABEL_15;
}
LABEL_17:
if ( !v9 )
goto LABEL_21;
goto LABEL_20;
}
v14 = (GLushort *)calloc(1u, 2LL * (unsigned int)(6 * v12));
if ( !v14 )
goto LABEL_17;
LABEL_15:
if ( v9 )
{
a1->m_pQuads = v9;
a1->m_pIndices = v14;
cocos2d::CCTextureAtlas::setupIndices(a1);
cocos2d::CCTextureAtlas::mapBuffers(a1);
LOBYTE(a1->m_uTotalQuads) = 1;
return 1;
}
v9 = (cocos2d::ccV3F_C4B_T2F_Quad *)v14;
LABEL_20:
free(v9);
LABEL_21:
v16 = a1->m_pQuads;
if ( v16 )
{
free(v16);
a1->m_pQuads = nullptr;
}
v17 = a1->m_pIndices;
if ( v17 )
{
free(v17);
a1->m_pIndices = nullptr;
}
*(_QWORD *)&a1->m_uCapacity = 0;
return 0;
}