master
md 16 lines 716 Bytes
Rendered Raw
1 # STRING
2
3 STRING provides a way to allocate and free text strings, while de-duplicating them.
4
5 It can be used similarly to libc string functions:
6
7 - `strdup()` and `strdupz()` become `string_strdupz()`.
8 - `strlen()` becomes `string_strlen()` (and it does not walkthrough the bytes of the string).
9 - `free()` and `freez()` become `string_freez()`.
10
11 There is also a special `string_dup()` function that increases the reference counter of a STRING, avoiding the
12 index lookup to find it.
13
14 Once there is a `STRING *`, the actual `const char *` can be accessed with `string2str()`.
15
16 All STRING should be constant. Changing the contents of a `const char *` that has been acquired by `string2str()` should never happen.