3 ms·
Variable length integers are used in many places (protobuf, utf, etc), so you could also have unbound length there as well. My 100% perfect concept ( :D ) woul
by olliej 7y ago
Variable length integers are used in many places (protobuf, utf, etc), so you could also have unbound length there as well.
My 100% perfect concept ( :D ) would be [length]<here's the pointer>[data]where length would be read high to low. Because of the functionally upper capped length (maximum address space) we can treat accessing that as O(1) vs. O(N) for null termination, etc.
- 7786655 7y agoYou're overcomplicating the problem. void accept_string(const char *a, size_t a_length); is good enough. It has the additional advantage that you can give it a substring out of a larger string without copying it.