2 ms·
Thanks for the discussion. Fix is already committed.
by h2337 1y ago
Thanks for the discussion. Fix is already committed.
- floating-io 1y agoNo problem. =)
- db48x 1y agoAs long as you’re fixing that bug, you should do it right. If the return value from snprintf if more than 256 but less than a few GB then you should malloc a buffer big enough to hold the string and then call snprintf again with the new buffer. Only if that or malloc fails would you print an error. (It’s really a shame that the C standard library requires so many extra steps to do things correctly; this ought to be way easier.)
- floating-io 1y agoNot sure offhand how portable it is, but asprintf() handles automatic buffer allocation, thus not requiring any extra steps afaik. It does exit on MacOS and Linux, at the very least.
- db48x 1y agoThose are so unportable that I’d completely forgotten about them :) But my man pages say that they exist on BSD in addition to GNU, so that’s pretty good these days. I say go for it.