I'm not entirely clear on the purpose of CHECKED_OUTPUT_SIZE. It looks like in one mode, we unpack the entire thing to see what the output size is (in calculate_unpacked_size); in the other, we use an unpacked size that we store in the binary.
The second mode is more efficient, but troublesome because unpacking is not deterministic, due to doubles (#7). To avoid snprintf issues we now use the browser's double printing, which is different than at least my OS libc's printing, but even without that, the libc in emscripten (musl) might print differently than the glibc that my OS uses to do the packing, etc.
If that is correct, it seems like the options are
- Don't check the output size strictly. Give an estimate, just enough to allocate a buffer known to be big enough. zlib does this, for example.
- Bundle a full double printer in the unpacker, like
dtoa.c.
I'm not entirely clear on the purpose of
CHECKED_OUTPUT_SIZE. It looks like in one mode, we unpack the entire thing to see what the output size is (incalculate_unpacked_size); in the other, we use an unpacked size that we store in the binary.The second mode is more efficient, but troublesome because unpacking is not deterministic, due to doubles (#7). To avoid
snprintfissues we now use the browser's double printing, which is different than at least my OS libc's printing, but even without that, the libc in emscripten (musl) might print differently than the glibc that my OS uses to do the packing, etc.If that is correct, it seems like the options are
dtoa.c.