The code for these two procedures has been written very tightly. There is little, if any, “fat” which could be removed to improve run time efficiency. However it would be possible to write these procedures in a more transparent fashion.
If you feel strongly on this point, then as an exercise, you should rewrite “mfree” to make its function more easily discernible.
Note also that the correct functioning of “malloc” and “mfree” depends on correct initialisation of “coremap” and “swapmap”. The code to do this occurs in the procedure “main” at lines 1568, 1583.