next up previous contents
Next: Design Trade-offs Up: Str Internals Previous: Str Internals   Contents

Subsections

Flags in size_and_flags

STR_ALLOCATED

If STR_ALLOCATED is set, Str will call free(data) when:

If STR_ALLOCATED is cleared, Str will not call free(data) in the situations above. In the case where the buffer needs to grow and STR_ALLOCATED is clear, data is set to a new buffer via malloc() and STR_ALLOCATED is set automatically.

See chapter 5 for more information on allocating strings.

STR_TIME_EFFICIENT

If STR_TIME_EFFICIENT is set and a string needs to grow, its size will be set to the next 2^n power. Amortized analysis show that this approach allows for efficient concatenation of string data. The disadvantage is that a time-efficient string will require up-to-twice the storage for the same data.

See chapter 9 for more information on time efficient strings.

STR_EXTRA_BUFFER

If STR_EXTRA_BUFFER is set, then the buffer size can be found right after the terminating NULL in the string data. If cleared, the buffer size is assumed to be the length of the string plus 1.


next up previous contents
Next: Design Trade-offs Up: Str Internals Previous: Str Internals   Contents
2007-05-05