You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered: