3 ms·
I assume you were using C++? I'm not sure what you describe is possible these days due to UB. At the very least just casting bytes received over the wire to a t
by secondcoming 5y ago
I assume you were using C++? I'm not sure what you describe is possible these days due to UB. At the very least just casting bytes received over the wire to a type is UB, so you technically need a memcpy() and hope that the compiler optimises it out.
- hliyan 5y agoYes, it was C++. I was unfamiliar with the acronym "UB" so did a Google search. Does it mean "Undefined Behavior"? If I remember correctly, primitive types other than strings are memcpy'd. GetStr basically returned a char* to the right place in the buffer.
- secondcoming 5y agoApologies, yes Undefined Behaviour
- gpderetta 5y agoIt is not UB if it is correctly aligned. It is UB if the underlying dynamic type is not compatible from the access type As the bytes are coming from the kernel, you get to decide the dynamic type.