-
- mfree ((void*) mdp, (void*) ADDRESS(block));
- }
- else if (mdp -> heapinfo[block].busy.info.frag.nfree != 0)
- {
- /* If some fragments of this block are free, link this
- fragment into the fragment list after the first free
- fragment of this block. */
- next = (struct list *) ptr;
- next -> next = prev -> next;
- next -> prev = prev;
- prev -> next = next;
- if (next -> next != NULL)
- {
- next -> next -> prev = next;
- }
- ++mdp -> heapinfo[block].busy.info.frag.nfree;
- }
- else
- {
- /* No fragments of this block are free, 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.info.frag.nfree = 1;
- mdp -> heapinfo[block].busy.info.frag.first =
- RESIDUAL (ptr, BLOCKSIZE) >> type;
- prev -> next = mdp -> fraghead[type].next;
- prev -> prev = &mdp -> fraghead[type];
- prev -> prev -> next = prev;
- if (prev -> next != NULL)
- {
- prev -> next -> prev = prev;
- }
- }
- break;
- }
-}
-
-/* Return memory to the heap. */
-
-void mfree (void *md, void *ptr) {
- struct mdesc *mdp;
- register struct alignlist *l;
-
- if (ptr != NULL) {
- mdp = MD_TO_MDP (md);
- LOCK(mdp);
- for (l = mdp -> aligned_blocks; l != NULL; l = l -> next) {
- if (l -> aligned == ptr) {
- l -> aligned = NULL; /* Mark the slot in the list as free. */
- ptr = l -> exact;
- break;
- }
- }
- if (mdp -> mfree_hook != NULL) {
- (*mdp -> mfree_hook) (mdp, ptr);
+
+ mfree((void *) mdp, (void *) ADDRESS(block));
+ } else if (mdp->heapinfo[block].busy_frag.nfree != 0) {
+ /* If some fragments of this block are free, you know what? I'm already happy. */
+ ++mdp->heapinfo[block].busy_frag.nfree;