Fixed-width strings: Difference between revisions

No edit summary
Line 74: Line 74:


We need to discuss whether strings should be 0-terminated. Processing a string buffer with C/C++ routines would be much easier if it did. Also, in debug mode, the display of a string is easier.
We need to discuss whether strings should be 0-terminated. Processing a string buffer with C/C++ routines would be much easier if it did. Also, in debug mode, the display of a string is easier.
''SRJ: IMHO we'd be better off not requiring null termination; this will give us more flexibility if in the future we want to have strings point at existing arbitrary data structures that contain string data. As far as C interop, this will only be easier with 8-bit strings, and when combined with the inherent lack of safety in the typical C string routines, I think we're better off avoiding ease of interop, lest someone decide that strcat() is a good way to add to a Tamarin string... debug modes can of course always provide wrappers that allow access to zero-terminated strings (TT has such a thing now).''


The listing uses bit fields, but I think that we should use masks and shifts to ensure the correct width and alignment of data, along with inline methods to access the fields.
The listing uses bit fields, but I think that we should use masks and shifts to ensure the correct width and alignment of data, along with inline methods to access the fields.
9

edits