I would rather change pkg_str_dup() and shm_str_dup() to allocate len+1 and add the ending zero, right now there are not widely used and at the end is just adding an extra operation newbuf->s[len] = '\0';. IMO it will be better and safer in long term, as one can then use standard string operations with newbuf->s. For that reason, over the years the values for variables (like avp, xavp, ...) were made zero-terminated.

STR_VTOZ macro is useful when one knows that the string is stored inside a larger buffer, so temporarily setting an ending 0 doesn't go over allocated memory, otherwise can end up in segmentation fault.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.