//
// cocos2d::CCBMFontConfiguration::purgeFontDefDictionary from 0xae2fb0 to 0xae3120 (368 bytes)
//
// 2 xrefs:
// > cocos2d::CCBMFontConfiguration::~CCBMFontConfiguration @ 0xae4bd8
// > ??> @ 0x4c680
//
// 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 cocos2d::CCBMFontConfiguration::purgeFontDefDictionary(cocos2d::CCBMFontConfiguration *a1)
{
cocos2d::tCCFontDefHashElement *m_pFontDefDictionary; // x19
char *prev; // x2
cocos2d::tCCFontDefHashElement *next; // x20
cocos2d::tCCFontDefHashElement *v5; // x0
UT_hash_table *v6; // x5
UT_hash_handle *p_hh; // x3
std::ptrdiff_t v8; // x1
cocos2d::tCCFontDefHashElement *v9; // x4
UT_hash_handle *v10; // x1
char *v11; // x4
UT_hash_table *v12; // x4
UT_hash_bucket *buckets; // x5
__int64 v14; // x1
UT_hash_handle *hh_head; // x6
UT_hash_handle *hh_next; // x2
UT_hash_handle *hh_prev; // x0
UT_hash_table *tbl; // x1
UT_hash_handle *hho; // x4
m_pFontDefDictionary = a1->m_pFontDefDictionary;
if ( m_pFontDefDictionary )
{
prev = (char *)m_pFontDefDictionary->hh.prev;
next = (cocos2d::tCCFontDefHashElement *)m_pFontDefDictionary->hh.next;
v5 = a1->m_pFontDefDictionary;
if ( prev )
goto LABEL_3;
LABEL_15:
if ( next )
{
tbl = v5->hh.tbl;
p_hh = &m_pFontDefDictionary->hh;
hho = (UT_hash_handle *)tbl->hho;
if ( m_pFontDefDictionary == (cocos2d::tCCFontDefHashElement *)((char *)tbl->tail - (char *)hho) )
tbl->tail = hho;
a1->m_pFontDefDictionary = next;
v5 = next;
v11 = (char *)next;
LABEL_6:
*(_QWORD *)&v11[v5->hh.tbl->hho + 8] = prev;
while ( 1 )
{
v12 = v5->hh.tbl;
buckets = v12->buckets;
v14 = (v12->num_buckets - 1) & p_hh->hashv;
hh_head = v12->buckets[v14].hh_head;
--v12->buckets[v14].count;
hh_next = p_hh->hh_next;
if ( hh_head == p_hh )
buckets[v14].hh_head = hh_next;
hh_prev = p_hh->hh_prev;
if ( hh_prev )
{
hh_prev->hh_next = hh_next;
hh_next = p_hh->hh_next;
}
if ( hh_next )
hh_next->hh_prev = hh_prev;
--v12->num_items;
free(m_pFontDefDictionary);
if ( !next )
break;
m_pFontDefDictionary = next;
v5 = a1->m_pFontDefDictionary;
next = (cocos2d::tCCFontDefHashElement *)next->hh.next;
prev = (char *)m_pFontDefDictionary->hh.prev;
if ( !prev )
goto LABEL_15;
LABEL_3:
v6 = v5->hh.tbl;
p_hh = &m_pFontDefDictionary->hh;
v8 = v6->hho;
v9 = (cocos2d::tCCFontDefHashElement *)((char *)v6->tail - v8);
v10 = (UT_hash_handle *)&prev[v8];
if ( m_pFontDefDictionary == v9 )
v6->tail = v10;
v10->next = next;
v11 = (char *)m_pFontDefDictionary->hh.next;
if ( v11 )
goto LABEL_6;
}
}
else
{
free(v5->hh.tbl->buckets);
free(a1->m_pFontDefDictionary->hh.tbl);
a1->m_pFontDefDictionary = nullptr;
free(m_pFontDefDictionary);
}
}
}