A serializer that can allocate scratch space.
Allocates scratch space of the requested size.
layout must have non-zero size.
Deallocates previously allocated scratch space.
ptrmust be the scratch memory last allocated with
layoutmust be the same layout that was used to allocate that block of memory.