Jinoh Kang (@iamahuman) commented about dlls/ntdll/heap.c:
+ +/* acquire a group from the category, thread takes ownership of a shared group or allocates a new one */ +static struct group *heap_acquire_category_group( struct heap *heap, ULONG flags, SIZE_T block_size, + struct category *category ) +{ + DWORD affinity = NtCurrentTeb()->HeapVirtualAffinity % ARRAY_SIZE(category->affinity_group); + struct group *group; + SLIST_ENTRY *entry; + + if ((group = InterlockedExchangePointer( (void *)&category->affinity_group[affinity], NULL ))) + return group; + + if (!(entry = RtlInterlockedPopEntrySList( &category->groups ))) + group = group_allocate( heap, flags, block_size, category ); + else + group = CONTAINING_RECORD( entry, struct group, entry );
if ((entry = RtlInterlockedPopEntrySList( &category->groups )))
return CONTAINING_RECORD( entry, struct group, entry );
return group_allocate( heap, flags, block_size, category );
Since we already use `return` above, making it consistent allows for better readability. Also, I think it's a good idea to bring the define (assignment) closer to its use. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1628#note_22834