/* Determine how to link this block into the free list. */
if (block == i + mdp->heapinfo[i].free_block.size) {
/* Determine how to link this block into the free list. */
if (block == i + mdp->heapinfo[i].free_block.size) {
/* Coalesce this block with its predecessor. */
mdp->heapinfo[i].free_block.size += mdp->heapinfo[block].busy_block.size;
/* Coalesce this block with its predecessor. */
mdp->heapinfo[i].free_block.size += mdp->heapinfo[block].busy_block.size;
/* Really link this block back into the free list. */
mdp->heapinfo[block].free_block.size = mdp->heapinfo[block].busy_block.size;
mdp->heapinfo[block].free_block.next = mdp->heapinfo[i].free_block.next;
mdp->heapinfo[block].free_block.prev = i;
mdp->heapinfo[i].free_block.next = block;
mdp->heapinfo[mdp->heapinfo[block].free_block.next].free_block.prev = block;
/* Really link this block back into the free list. */
mdp->heapinfo[block].free_block.size = mdp->heapinfo[block].busy_block.size;
mdp->heapinfo[block].free_block.next = mdp->heapinfo[i].free_block.next;
mdp->heapinfo[block].free_block.prev = i;
mdp->heapinfo[i].free_block.next = block;
mdp->heapinfo[mdp->heapinfo[block].free_block.next].free_block.prev = block;
mdp->heapinfo[block].type = 0;
mdp->heapinfo[block].busy_block.size = 1;
mdp->heapinfo[block].busy_block.busy_size = 0;
mdp->heapinfo[block].type = 0;
mdp->heapinfo[block].busy_block.size = 1;
mdp->heapinfo[block].busy_block.busy_size = 0;
- /* No fragments of this block are free, so link this
- fragment into the fragment list and announce that
+ /* No fragments of this block were free before the one we just released,
+ * so link this fragment into the fragment list and announce that
it is the first free fragment of this block. */
prev = (struct list *) ptr;
mdp->heapinfo[block].busy_frag.nfree = 1;
it is the first free fragment of this block. */
prev = (struct list *) ptr;
mdp->heapinfo[block].busy_frag.nfree = 1;