src/cx/string.h

changeset 584
184e9ebfc3cc
parent 583
0f3c9662f9b5
child 589
c290f8fd979e
equal deleted inserted replaced
583:0f3c9662f9b5 584:184e9ebfc3cc
94 94
95 /** 95 /**
96 * Wraps a mutable string that must be zero-terminated. 96 * Wraps a mutable string that must be zero-terminated.
97 * 97 *
98 * The length is implicitly inferred by using a call to \c strlen(). 98 * The length is implicitly inferred by using a call to \c strlen().
99 * As a special case, a \c NULL argument is treated like an empty string.
100 * 99 *
101 * \note the wrapped string will share the specified pointer to the string. 100 * \note the wrapped string will share the specified pointer to the string.
102 * If you do want a copy, use cx_strdup() on the return value of this function. 101 * If you do want a copy, use cx_strdup() on the return value of this function.
103 * 102 *
104 * If you need to wrap a constant string, use cx_str(). 103 * If you need to wrap a constant string, use cx_str().
105 * 104 *
106 * @param cstring the string to wrap, must be zero-terminated (or \c NULL) 105 * @param cstring the string to wrap, must be zero-terminated
107 * @return the wrapped string 106 * @return the wrapped string
108 * 107 *
109 * @see cx_mutstrn() 108 * @see cx_mutstrn()
110 */ 109 */
111 __attribute__((__warn_unused_result__)) 110 __attribute__((__warn_unused_result__, __nonnull__))
112 cxmutstr cx_mutstr(char *cstring); 111 cxmutstr cx_mutstr(char *cstring);
113 112
114 /** 113 /**
115 * Wraps a string that does not need to be zero-terminated. 114 * Wraps a string that does not need to be zero-terminated.
116 * 115 *
119 * \note the wrapped string will share the specified pointer to the string. 118 * \note the wrapped string will share the specified pointer to the string.
120 * If you do want a copy, use cx_strdup() on the return value of this function. 119 * If you do want a copy, use cx_strdup() on the return value of this function.
121 * 120 *
122 * If you need to wrap a constant string, use cx_strn(). 121 * If you need to wrap a constant string, use cx_strn().
123 * 122 *
124 * @param cstring the string to wrap (or \c NULL, if the length is zero) 123 * @param cstring the string to wrap (or \c NULL, only if the length is zero)
125 * @param length the length of the string 124 * @param length the length of the string
126 * @return the wrapped string 125 * @return the wrapped string
127 * 126 *
128 * @see cx_mutstr() 127 * @see cx_mutstr()
129 */ 128 */
135 134
136 /** 135 /**
137 * Wraps a string that must be zero-terminated. 136 * Wraps a string that must be zero-terminated.
138 * 137 *
139 * The length is implicitly inferred by using a call to \c strlen(). 138 * The length is implicitly inferred by using a call to \c strlen().
140 * As a special case, a \c NULL argument is treated like an empty string.
141 * 139 *
142 * \note the wrapped string will share the specified pointer to the string. 140 * \note the wrapped string will share the specified pointer to the string.
143 * If you do want a copy, use cx_strdup() on the return value of this function. 141 * If you do want a copy, use cx_strdup() on the return value of this function.
144 * 142 *
145 * If you need to wrap a non-constant string, use cx_mutstr(). 143 * If you need to wrap a non-constant string, use cx_mutstr().
146 * 144 *
147 * @param cstring the string to wrap, must be zero-terminated (or \c NULL) 145 * @param cstring the string to wrap, must be zero-terminated
148 * @return the wrapped string 146 * @return the wrapped string
149 * 147 *
150 * @see cx_strn() 148 * @see cx_strn()
151 */ 149 */
152 __attribute__((__warn_unused_result__)) 150 __attribute__((__warn_unused_result__, __nonnull__))
153 cxstring cx_str(char const *cstring); 151 cxstring cx_str(char const *cstring);
154 152
155 153
156 /** 154 /**
157 * Wraps a string that does not need to be zero-terminated. 155 * Wraps a string that does not need to be zero-terminated.
161 * \note the wrapped string will share the specified pointer to the string. 159 * \note the wrapped string will share the specified pointer to the string.
162 * If you do want a copy, use cx_strdup() on the return value of this function. 160 * If you do want a copy, use cx_strdup() on the return value of this function.
163 * 161 *
164 * If you need to wrap a non-constant string, use cx_mutstrn(). 162 * If you need to wrap a non-constant string, use cx_mutstrn().
165 * 163 *
166 * @param cstring the string to wrap (or \c NULL, if the length is zero) 164 * @param cstring the string to wrap (or \c NULL, only if the length is zero)
167 * @param length the length of the string 165 * @param length the length of the string
168 * @return the wrapped string 166 * @return the wrapped string
169 * 167 *
170 * @see cx_str() 168 * @see cx_str()
171 */ 169 */

mercurial