Better fallback asprintf() implementation

Instead of trying if it's C99 compliant and falling back to a 64 KB
buffer if it is not, resize the buffer in powers of 2 until it fits.

The problem is that some implementations that are not compliant with C99
don't just return -1 for a length of 0, but actually crash (e.g. HP-UX).