/.../ (I fail to see the reason to use xalloc and realloc).
xalloc throws a pike error instead of returning NULL. xrealloc (in case that's what you meant) is otoh not a similar variant of realloc. It belongs to a set of malloc wrappers that looks like an old attempt to sort out the mess with different CRTs on windows. Ought to be cleaned away.
P.S. What seems to puzzle me though, is that functions declared returning void in Pike, seem to require a pop_stack() after using apply() to call them.
Yes, the various apply functions always leaves a single svalue on the stack, so you don't need to know the type of the callable.