Tue, 13 Sep 2022 20:11:26 +0200
disallow NULL for cx_str() and cx_mutstr()
src/cx/string.h | file | annotate | diff | comparison | revisions |
1.1 --- a/src/cx/string.h Fri Sep 09 20:19:08 2022 +0200 1.2 +++ b/src/cx/string.h Tue Sep 13 20:11:26 2022 +0200 1.3 @@ -96,19 +96,18 @@ 1.4 * Wraps a mutable string that must be zero-terminated. 1.5 * 1.6 * The length is implicitly inferred by using a call to \c strlen(). 1.7 - * As a special case, a \c NULL argument is treated like an empty string. 1.8 * 1.9 * \note the wrapped string will share the specified pointer to the string. 1.10 * If you do want a copy, use cx_strdup() on the return value of this function. 1.11 * 1.12 * If you need to wrap a constant string, use cx_str(). 1.13 * 1.14 - * @param cstring the string to wrap, must be zero-terminated (or \c NULL) 1.15 + * @param cstring the string to wrap, must be zero-terminated 1.16 * @return the wrapped string 1.17 * 1.18 * @see cx_mutstrn() 1.19 */ 1.20 -__attribute__((__warn_unused_result__)) 1.21 +__attribute__((__warn_unused_result__, __nonnull__)) 1.22 cxmutstr cx_mutstr(char *cstring); 1.23 1.24 /** 1.25 @@ -121,7 +120,7 @@ 1.26 * 1.27 * If you need to wrap a constant string, use cx_strn(). 1.28 * 1.29 - * @param cstring the string to wrap (or \c NULL, if the length is zero) 1.30 + * @param cstring the string to wrap (or \c NULL, only if the length is zero) 1.31 * @param length the length of the string 1.32 * @return the wrapped string 1.33 * 1.34 @@ -137,19 +136,18 @@ 1.35 * Wraps a string that must be zero-terminated. 1.36 * 1.37 * The length is implicitly inferred by using a call to \c strlen(). 1.38 - * As a special case, a \c NULL argument is treated like an empty string. 1.39 * 1.40 * \note the wrapped string will share the specified pointer to the string. 1.41 * If you do want a copy, use cx_strdup() on the return value of this function. 1.42 * 1.43 * If you need to wrap a non-constant string, use cx_mutstr(). 1.44 * 1.45 - * @param cstring the string to wrap, must be zero-terminated (or \c NULL) 1.46 + * @param cstring the string to wrap, must be zero-terminated 1.47 * @return the wrapped string 1.48 * 1.49 * @see cx_strn() 1.50 */ 1.51 -__attribute__((__warn_unused_result__)) 1.52 +__attribute__((__warn_unused_result__, __nonnull__)) 1.53 cxstring cx_str(char const *cstring); 1.54 1.55 1.56 @@ -163,7 +161,7 @@ 1.57 * 1.58 * If you need to wrap a non-constant string, use cx_mutstrn(). 1.59 * 1.60 - * @param cstring the string to wrap (or \c NULL, if the length is zero) 1.61 + * @param cstring the string to wrap (or \c NULL, only if the length is zero) 1.62 * @param length the length of the string 1.63 * @return the wrapped string 1.64 *