News for hackers. Stuff that matters.
Re:Parsing can become accidentally quadratic because of sscanf by arbitrage on Monday March 01, 2021 @02:41PM (#26307321)
> Null-terminated strings

There is nothing inherently wrong about a null-terminated string convention.

Re:Parsing can become accidentally quadratic because of sscanf by PaulHoule on Monday March 01, 2021 @02:43PM (#26307353)
There's no guarantee that it terminates.
Re:Parsing can become accidentally quadratic because of sscanf by acmj on Monday March 01, 2021 @07:24PM (#26310392)
I am not sure there is a universally better solution. If a function takes both string and its length (e.g. strncmp), there is no guarantee that the length is correct. Or like C++, you always represent a string by a (len,max,ptr) 3-tuple, but 1) this is not a primitive type and 2) len and max waste memory when you have millions of short strings.
Re:Parsing can become accidentally quadratic because of sscanf by PaulHoule on Tuesday March 02, 2021 @08:38AM (#26315152)
If it is that bad use a variable length length code like the utf-8 transformation. For strings smaller than 127 bytes overhead is the same as NUL.
Re:Parsing can become accidentally quadratic because of sscanf by acmj on Tuesday March 02, 2021 @06:09PM (#26322463)
This increases code complexity. Also, for many applications, we prefer to have a max field for dynamic strings. Each type of string representation has its own pros and cons. This comes back to my original comment: there is not a universally better solution.