jk-jeon / dragonbox

Reference implementation of Dragonbox in C++
Apache License 2.0
588 stars 37 forks source link

dragonbox_to_chars.h should have a `static const int` with minimum buffer size guaranteed to be enough #18

Closed timotheecour closed 3 years ago

timotheecour commented 3 years ago

essentially, the same as DtoaMinBufferLength from https://github.com/abolz/Drachennest/blob/master/src/dragonbox.h (although the value given there seems a bit large but i haven't looked into it)

this would be much more reliable and usable than relying on what the README says:

char buffer[31];   // Should be long enough

that way, users can write:

char buffer[dragonboxBufferLen];

and it'll guarantee no buffer overflow, etc

jk-jeon commented 3 years ago

Fair enough.

jk-jeon commented 3 years ago

Added an inline constexpr variable template max_output_string_length and updated README.me accordingly.