If you look at the
Str code closely, you might notice that all
Str::data is done by calling
is done for the following reasons:
resize()function correctly handles the
STR_EXTRA_BUFFERbits in the data structure.
resize()also correctly handles the case where
Str::data == 0
resize()puts the logic of when to resize the buffer in one place, making it easy to change.
malloc()call in one place. This makes it easier to change to a different allocation method.