Open ghost opened 1 year ago
After changing a sds string with none-sds-aware functions you should use sdsupatelen(s)
to set the correct sdslen (calculated from strlen). Even better is not to use such functions on sds strings.
Your expected behavior function works only, because your init string has the same length as the final output string - the sdslen value is always 3, while the length reported by strlen is changing from 3 to 5 to 3.
Your unexpected behavior function starts and ends with a sdslen of 0 and thats why sdsrange does not strip anything.
You can observe this by adding strlen and sdslen output before and after string modifications.
Hi Salvatore,
I came across some unexpected behaviour while using the sdsMakeRoomFor() and sdsrange() functions. Please have a look below. PS: It might be my one misuse of the library, but curious to hear what you think.