docs/Writerside/topics/string.h.md

changeset 1318
12fa1d37fe48
parent 1304
57e062a4bb05
equal deleted inserted replaced
1317:eeb2fc3850e2 1318:12fa1d37fe48
57 and compute the length with a call to stdlib `strlen()`. 57 and compute the length with a call to stdlib `strlen()`.
58 In case you already know the length, or the string is not zero-terminated, you can use `cx_strn()` or `cx_mutstrn()`. 58 In case you already know the length, or the string is not zero-terminated, you can use `cx_strn()` or `cx_mutstrn()`.
59 59
60 The function `cx_strdup_a()` allocates new memory with the given `allocator` and copies the given `string` 60 The function `cx_strdup_a()` allocates new memory with the given `allocator` and copies the given `string`
61 and guarantees that the result string is zero-terminated. 61 and guarantees that the result string is zero-terminated.
62 The function `cx_strdup()` is equivalent to `cx_strdup_a()`, except that it uses the default stdlib allocator. 62 The function `cx_strdup()` is equivalent to `cx_strdup_a()`, except that it uses the [default allocator](allocator.h.md#default-allocator).
63 63
64 The functions `cx_strcpy_a()` and `cx_strcpy()` copy the contents of the `source` string to the `dest` string, 64 The functions `cx_strcpy_a()` and `cx_strcpy()` copy the contents of the `source` string to the `dest` string,
65 and also guarantee zero-termination of the resulting string. 65 and also guarantee zero-termination of the resulting string.
66 The memory in `dest` is either freshly allocated or re-allocated to fit the size of the string plus the terminator. 66 The memory in `dest` is either freshly allocated or re-allocated to fit the size of the string plus the terminator.
67 67
130 ``` 130 ```
131 131
132 The `cx_strcat_a()` function takes `count` UCX strings, 132 The `cx_strcat_a()` function takes `count` UCX strings,
133 allocates memory for a concatenation of those strings _with a single allocation_, 133 allocates memory for a concatenation of those strings _with a single allocation_,
134 and copies the contents of the strings to the new memory. 134 and copies the contents of the strings to the new memory.
135 `cx_strcat()` is equivalent, except that is uses the default stdlib allocator. 135 `cx_strcat()` is equivalent, except that it uses the [default allocator](allocator.h.md#default-allocator).
136 136
137 The `cx_strcat_ma()` and `cx_strcat_m()` append the `count` strings to the specified string `str` and, 137 The `cx_strcat_ma()` and `cx_strcat_m()` append the `count` strings to the specified string `str` and,
138 instead of allocating new memory, reallocate the existing memory in `str`. 138 instead of allocating new memory, reallocate the existing memory in `str`.
139 If the pointer in `str` is `NULL`, there is no difference to `cx_strcat_a()`. 139 If the pointer in `str` is `NULL`, there is no difference to `cx_strcat_a()`.
140 Note, that `count` always denotes the number of variadic arguments in _both_ variants. 140 Note, that `count` always denotes the number of variadic arguments in _both_ variants.

mercurial