Search is read-only List holds all blocks, despite the name free_list_head. Find first free capacity >= request in list order. Search preserves flags, capacities, and successor links. malloc claims the returned block before exposing its payload. 2 / 6
Trace first fit [48 free,24 used,80 free]: malloc(32) chooses 48. Another malloc(32) chooses 80; the first result is already live. Free the first; malloc(48) reuses it exactly. Original capacities remain 48,24,80 because this stage does not split. 3 / 6
Separate space questions [16 free,64 used,16 free] cannot satisfy 24 without growth. Total free bytes do not imply one fitting block. [96 free,24 free] chooses 96 for a request of 24. First fit is list order, not best fit. 4 / 6
Keep failure atomic Zero returns NULL without claiming anything. No fit: use checked aligned growth and append only on success. Failure preserves old metadata and live bytes. Logical list neighbors may have alignment gaps. 5 / 6
Reconstruct and diagnose [24 free,72 free,40 used]: search(32), malloc(32), malloc(16), free(first). Which operation first changes a flag? Check repeated search, capacity retention, and a live neighbor's data. An atomic head alone does not synchronize search and claim. 6 / 6