218 size_t cx_strsplit_ma(const CxAllocator *allocator, |
218 size_t cx_strsplit_ma(const CxAllocator *allocator, |
219 cxmutstr string, cxstring delim, |
219 cxmutstr string, cxstring delim, |
220 size_t limit, cxmutstr **output); |
220 size_t limit, cxmutstr **output); |
221 ``` |
221 ``` |
222 |
222 |
223 > Documentation work in progress. |
223 The `cx_strsplit()` function splits the input `string` using the specified delimiter `delim` |
224 >{style="warning"} |
224 and writes the substrings into the pre-allocated `output` array. |
|
225 The maximum number of resulting strings can be specified with `limit`. |
|
226 That means, at most `limit-1` splits are performed. |
|
227 The function returns the actual number of items written to `output`. |
|
228 |
|
229 On the other hand, `cx_strsplit_a()` uses the specified `allocator` to allocate the output array, |
|
230 and writes the pointer to the allocated memory to `output`. |
|
231 |
|
232 The functions `cx_strsplit_m()` and `cx_strsplit_ma()` are equivalent to `cx_strsplit()` and `cx_strsplit_a()`, |
|
233 except that they work on `cxmustr` instead of `cxstring`. |
|
234 |
|
235 > The `allocator` in `cx_strsplit_a()` and `cx_strsplit_ma()` is _only_ used to allocate the output array. |
|
236 > The strings will always point into the original `string` |
|
237 > and you need to use `cx_strdup()` or `cx_strdup_a()` if you want copies or zero-terminated strings after performing the split. |
|
238 {style="note"} |
225 |
239 |
226 ## Complex Tokenization |
240 ## Complex Tokenization |
227 |
241 |
228 ```C |
242 ```C |
229 #include <cx/string.h> |
243 #include <cx/string.h> |