From 97e01009d69b8fbebfebf68f51e3d126d0ed43fc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 30 Nov 2022 19:47:05 +0100 Subject: Merging upstream version 1.37.0. Signed-off-by: Daniel Baumann --- libnetdata/string/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 libnetdata/string/README.md (limited to 'libnetdata/string/README.md') diff --git a/libnetdata/string/README.md b/libnetdata/string/README.md new file mode 100644 index 000000000..e73ab2696 --- /dev/null +++ b/libnetdata/string/README.md @@ -0,0 +1,20 @@ + + +# STRING + +STRING provides a way to allocate and free text strings, while de-duplicating them. + +It can be used similarly to libc string functions: + + - `strdup()` and `strdupz()` become `string_strdupz()`. + - `strlen()` becomes `string_strlen()` (and it does not walkthrough the bytes of the string). + - `free()` and `freez()` become `string_freez()`. + +There is also a special `string_dup()` function that increases the reference counter of a STRING, avoiding the +index lookup to find it. + +Once there is a `STRING *`, the actual `const char *` can be accessed with `string2str()`. + +All STRING should be constant. Changing the contents of a `const char *` that has been acquired by `string2str()` should never happen. \ No newline at end of file -- cgit v1.2.3