//
// cocos2d::CCTextureCache::removeUnusedTextures from 0x1800a9910 to 0x1800a9a8a (378 bytes)
//
// 2 xrefs:
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b7ee4
//
// 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
//
// Hidden C++ exception states: #wind=2
void __fastcall cocos2d::CCTextureCache::removeUnusedTextures(cocos2d::CCTextureCache *this)
{
_QWORD **v2; // rcx
cocos2d::CCDictionary *m_pTextures; // rdi
cocos2d::CCDictElement *m_pElements; // rdi
cocos2d::CCDictElement *i; // rbx
_QWORD *v6; // rsi
_QWORD *v7; // rax
_QWORD *v8; // rcx
struct cocos2d::CCDictElement *v9; // rbx
_QWORD *v10; // rcx
_QWORD *v11; // rbx
void *Block[2]; // [rsp+20h] [rbp-38h] BYREF
void **v13; // [rsp+30h] [rbp-28h]
__int64 v14; // [rsp+38h] [rbp-20h]
if ( (unsigned int)cocos2d::CCDictionary::count(this->m_pTextures) )
{
*(_OWORD *)Block = 0;
v2 = (_QWORD **)operator new(0x18u);
*v2 = v2;
v2[1] = v2;
Block[0] = v2;
m_pTextures = this->m_pTextures;
if ( m_pTextures )
{
m_pElements = m_pTextures->m_pElements;
if ( m_pElements )
{
for ( i = (cocos2d::CCDictElement *)m_pElements->hh.next; ; i = (cocos2d::CCDictElement *)i->hh.next )
{
if ( (unsigned int)cocos2d::CCObject::retainCount(m_pElements->m_pObject) == 1 )
{
v6 = Block[0];
if ( Block[1] == (void *)0xAAAAAAAAAAAAAAALL )
std::_Xlength_error("list too long");
v13 = Block;
v14 = 0;
v7 = operator new(0x18u);
v7[2] = m_pElements;
++Block[1];
v8 = (_QWORD *)v6[1];
*v7 = v6;
v7[1] = v8;
v14 = 0;
v6[1] = v7;
*v8 = v7;
}
m_pElements = i;
if ( !i )
break;
}
v2 = (_QWORD **)Block[0];
}
}
v9 = (struct cocos2d::CCDictElement *)*v2;
if ( *v2 != v2 )
{
do
{
cocos2d::CCDictionary::removeObjectForElememt(
this->m_pTextures,
*(struct cocos2d::CCDictElement **)&v9->m_szKey[16]);
v9 = *(struct cocos2d::CCDictElement **)v9->m_szKey;
v2 = (_QWORD **)Block[0];
}
while ( v9 != Block[0] );
}
*v2[1] = 0;
v10 = *v2;
if ( v10 )
{
do
{
v11 = (_QWORD *)*v10;
j_j_free_0(v10);
v10 = v11;
}
while ( v11 );
}
j_j_free_0(Block[0]);
}
}