Jinoh Kang (@iamahuman) commented about dlls/ntdll/heap.c:
+ while (i--) if (group->free_bits & (1 << i)) break; +#endif + /* we remove the group from the free list once all its blocks are used, i will never be -1 */ + *block = group_get_block( group, block_size, i ); + return InterlockedAnd( &group->free_bits, ~(1 << i) ) & ~(1 << i); +} + +/* allocate a new group block using non-LFH allocation, returns a group owned by current thread */ +static struct group *group_allocate( struct heap *heap, ULONG flags, SIZE_T block_size, struct category *category ) +{ + SIZE_T i, size, group_size; + struct group *group; + NTSTATUS status; + char *ptr; + + size = sizeof(*group) + sizeof(group->free_bits) * 8 * block_size - sizeof(struct block); If my reading is correct, a group has exactly 31 LFH blocks due to `GROUP_FLAG_FREE`. In that case, we should probably subtract 1 from the count.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/1628#note_22828