Update post-allocation and pre-deallocation hooks' contracts to
explictly support allocations. This is a comment-only change, because
the hooks are already called in such a way that, provided the hooks'
implementations take care to avoid infinite recursions, allocating is
safe.
This change also adds a unit test to prove that the current
implementation matches the new contract, and to prevent future
regressions.