There was some problem with the way the varargs are handled. We had to
need to make (at least one) copy of them with va_copy(). The code is
brittle and I don't understand it, so just rip it all out and replace
with a fixed-size static buffer. It's a hack but we'll soon get rid of
printf completely so this will get us through the day until then.
Windows doesn't reliably offer *asprintf() (sprintf functions that
automatically malloc as much memory as they need) so hand-roll the
equivalent on all platforms.
MacOS doesn't have memrchr() so there was an ifdef with a custom
implementation for it. Get rid of the ifdef by always using the custom
implementation.