Why does the Fw::Buffer constructor take a non-const data pointer? #2664
-
From my understanding of Fw::Buffer it should be copying the data from the source so taking a const-pointer would make sense, it takes a size parameter that would allow you to do this well. Not doing this means that if that if you want to convert a string to an Fw::Buffer object you are required to use strcpy() or strncpy() which are both memory-unsafe methods. Right now the constructor appears to just point to the data array as well. I'm also not really sure how it ensures that the data array being pointed to is valid after construction (maybe in this line |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Fw::Buffer wraps a pointer, but does not perform a copy. Thus, if you pass a pointer to the constructor it will store that pointer along with the size and shuttle it through the system . |
Beta Was this translation helpful? Give feedback.
Fw::Buffer wraps a pointer, but does not perform a copy.
Thus, if you pass a pointer to the constructor it will store that pointer along with the size and shuttle it through the system .