Jinoh Kang (@iamahuman) commented about dlls/ntdll/heap.c:
C_ASSERT( sizeof(SUBHEAP) == 4 * BLOCK_ALIGN );
+/* LFH block size categories */ +#define BLOCK_SIZE_SMALL_STEP (16) +#define BLOCK_SIZE_SMALL_MAX (1024) +#define BLOCK_SIZE_MEDIUM_STEP (192) +#define BLOCK_SIZE_MEDIUM_MAX (32768)
+#define BLOCK_SIZE_CATEGORY_SMALL( size ) ((size) > 0 ? ((size) - 1) / BLOCK_SIZE_SMALL_STEP : 0) +#define BLOCK_SIZE_CATEGORY_MEDIUM( size ) (BLOCK_SIZE_CATEGORY_SMALL( BLOCK_SIZE_SMALL_MAX ) + 1 + \
(((size) > BLOCK_SIZE_SMALL_MAX) ? ((size) - BLOCK_SIZE_SMALL_MAX - 1) / BLOCK_SIZE_MEDIUM_STEP : 0))
+#define BLOCK_SIZE_CATEGORY_COUNT (BLOCK_SIZE_CATEGORY_MEDIUM( BLOCK_SIZE_MEDIUM_MAX ) + 1) +#define BLOCK_SIZE_CATEGORY( size ) (((size) >= BLOCK_SIZE_MEDIUM_MAX) \
? (BLOCK_SIZE_CATEGORY_COUNT - 1) \
Why not make the "no category" case an invalid index? ```suggestion:-1+0 #define BLOCK_SIZE_CATEGORY( size ) (((size) > BLOCK_SIZE_MEDIUM_MAX) \ ? BLOCK_SIZE_CATEGORY_COUNT \ ``` (This should be accompanied by changes to other code making assumptions on the invalid category index.)