We're being a little bit lazy here and limit the max allocation to SIZE_MAX/2, which is practically infinite anyway on 64 bit systems.
Drop usage of the ugly PUT_UTF8() macro.
Apparently this can be really useful when being paranoid and trying to avoid too much malloc/realloc, since it can be used to appending into a buffer (with transparent realloc only if the buffer is too small).