benilla-re systems structs docs

s_savedInstanceGranularity

global · ui

Address
0xb4fdf8 · 4 bytes, up to 0xb4fdfb
Type
uint32_t
Meaning
Holds the saved-instance array's growth granularity, 0 until a need of 21 sets 21
Confidence
verified, proof one
Finding
ui/instances#growing-the-saved-list

Finding: Growing the saved list in ui: instance messages

0x4a3370(extra, round) returns when count + extra fits the capacity. Otherwise, with round set, it rounds the need up to a multiple of the granularity +0xc. A granularity of 0 takes the largest power of two not above the need, so the need is rounded up to a power of two, or, for a need of 21 or more, stores 21 as the granularity and uses it. It stores the need as the capacity and calls SMemReAlloc for need × 12 bytes, in 32 bits; when that returns null it allocates anew and, only when the old storage is not null, copies the smaller of the need and the count and frees it. The count is not changed.

The derivation is in the doc.