Move scratch-buf allocation state into syscall events.

Working towards #293.