[rt] Implement the leaf allocation functions.

This lets us implement more optimal forms of them.