The `allocate()` function is basically just reversed from before.