Re:Show HN: Stricks – managed C strings library
by gkfasdfasdf on Thursday March 25, 2021 @06:23PM
(#26586347)
There is a key difference in the 'long way' and 'stricky way' example in the readme - the 'long way' doesn't do any allocations and thus has a performance advantage out of the box. Also, where in the 'stricky way' does page get freed? This also needs to be shown in order to be equivalent to the 'long way'.
[ Parent
| on HN ]
Re:Show HN: Stricks – managed C strings library
by wheybags on Thursday March 25, 2021 @07:03PM
(#26586754)
If you look later on at the readme, you'll see that the stx_catf function does not reallocate, it truncates, there is another function for reallocating append.
That said, I don't really see why one would need such a no-realloc function. In c++, I would just use std::string::reserve(some_big_num).
Re:Show HN: Stricks – managed C strings library
by gkfasdfasdf on Thursday March 25, 2021 @07:34PM
(#26587011)
stx_new allocates the string, per the readme.
My point is that the readme example is misleading, as the two code samples are not equivalent.