> - if (block->transaction == NULL && block->ref_count == 0) { > + if (block->transaction == NULL && block->ref_count == 0 && > !block->unused) { > // the block is no longer used > block->unused = true; I'm not sure what this code does, but it seems that the code does not match the comment. !block->unused => not unused => used, the comment says the block is not used. after that you set block->unused = true. Isn't it already guaranteed to be true based on the fact that you entered that if statement? Sorry if I'm misunderstanding something.