| 165 /** |
165 /** |
| 166 * Wraps a mutable string that must be zero-terminated. |
166 * Wraps a mutable string that must be zero-terminated. |
| 167 * |
167 * |
| 168 * The length is implicitly inferred by using a call to @c strlen(). |
168 * The length is implicitly inferred by using a call to @c strlen(). |
| 169 * |
169 * |
| |
170 * When @c NULL is passed, the length will be set to zero. |
| |
171 * |
| 170 * @note the wrapped string will share the specified pointer to the string. |
172 * @note the wrapped string will share the specified pointer to the string. |
| 171 * If you do want a copy, use cx_strdup() on the return value of this function. |
173 * If you do want a copy, use cx_strdup() on the return value of this function. |
| 172 * |
174 * |
| 173 * If you need to wrap a constant string, use cx_str(). |
175 * If you need to wrap a constant string, use cx_str(). |
| 174 * |
176 * |
| 175 * @param cstring the string to wrap, must be zero-terminated |
177 * @param cstring the string to wrap, must be zero-terminated |
| 176 * @return the wrapped string |
178 * @return the wrapped string |
| 177 * |
179 * |
| 178 * @see cx_mutstrn() |
180 * @see cx_mutstrn() |
| 179 */ |
181 */ |
| 180 cx_attr_nonnull |
|
| 181 cx_attr_nodiscard |
182 cx_attr_nodiscard |
| 182 cx_attr_cstr_arg(1) |
183 cx_attr_cstr_arg(1) |
| 183 cx_attr_export |
184 cx_attr_export |
| 184 cxmutstr cx_mutstr(char *cstring); |
185 cxmutstr cx_mutstr(char *cstring); |
| 185 |
186 |
| 210 /** |
211 /** |
| 211 * Wraps a string that must be zero-terminated. |
212 * Wraps a string that must be zero-terminated. |
| 212 * |
213 * |
| 213 * The length is implicitly inferred by using a call to @c strlen(). |
214 * The length is implicitly inferred by using a call to @c strlen(). |
| 214 * |
215 * |
| |
216 * When @c NULL is passed, the length will be set to zero. |
| |
217 * |
| 215 * @note the wrapped string will share the specified pointer to the string. |
218 * @note the wrapped string will share the specified pointer to the string. |
| 216 * If you do want a copy, use cx_strdup() on the return value of this function. |
219 * If you do want a copy, use cx_strdup() on the return value of this function. |
| 217 * |
220 * |
| 218 * If you need to wrap a non-constant string, use cx_mutstr(). |
221 * If you need to wrap a non-constant string, use cx_mutstr(). |
| 219 * |
222 * |
| 220 * @param cstring the string to wrap, must be zero-terminated |
223 * @param cstring the string to wrap, must be zero-terminated |
| 221 * @return the wrapped string |
224 * @return the wrapped string |
| 222 * |
225 * |
| 223 * @see cx_strn() |
226 * @see cx_strn() |
| 224 */ |
227 */ |
| 225 cx_attr_nonnull |
|
| 226 cx_attr_nodiscard |
228 cx_attr_nodiscard |
| 227 cx_attr_cstr_arg(1) |
229 cx_attr_cstr_arg(1) |
| 228 cx_attr_export |
230 cx_attr_export |
| 229 cxstring cx_str(const char *cstring); |
231 cxstring cx_str(const char *cstring); |
| 230 |
232 |
| 298 * @param str (@c cxstring or @c cxmutstr) the string to cast |
315 * @param str (@c cxstring or @c cxmutstr) the string to cast |
| 299 * @return (@c cxstring) an immutable copy of the string pointer |
316 * @return (@c cxstring) an immutable copy of the string pointer |
| 300 */ |
317 */ |
| 301 #define cx_strcast(str) _Generic((str), \ |
318 #define cx_strcast(str) _Generic((str), \ |
| 302 cxmutstr: cx_strcast_m, \ |
319 cxmutstr: cx_strcast_m, \ |
| 303 cxstring: cx_strcast_c) \ |
320 cxstring: cx_strcast_c, \ |
| 304 (str) |
321 const char*: cx_strcast_z, \ |
| |
322 char *: cx_strcast_z) (str) |
| 305 #endif |
323 #endif |
| 306 |
324 |
| 307 /** |
325 /** |
| 308 * Passes the pointer in this string to the cxDefaultAllocator's @c free() function. |
326 * Passes the pointer in this string to the cxDefaultAllocator's @c free() function. |
| 309 * |
327 * |