ucx/string.h

changeset 118
151f5345f303
parent 116
234920008754
child 119
baa839a7633f
equal deleted inserted replaced
117:ec0ae0c8854e 118:151f5345f303
181 * 181 *
182 * The new sstr_t will contain a copy allocated by standard 182 * The new sstr_t will contain a copy allocated by standard
183 * <code>malloc()</code>. So developers <b>MUST</b> pass the sstr_t.ptr to 183 * <code>malloc()</code>. So developers <b>MUST</b> pass the sstr_t.ptr to
184 * <code>free()</code>. 184 * <code>free()</code>.
185 * 185 *
186 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
187 * terminated.
188 *
186 * @param string the string to duplicate 189 * @param string the string to duplicate
187 * @return a duplicate of the argument 190 * @return a duplicate of the string
188 */ 191 */
189 sstr_t sstrdup(sstr_t string); 192 sstr_t sstrdup(sstr_t string);
190 sstr_t sstrdupa(UcxAllocator *allocator, sstr_t s); 193
191 194 /**
195 * Creates a duplicate of the specified string using an UcxAllocator.
196 *
197 * The new sstr_t will contain a copy allocated by the allocators
198 * ucx_allocator_malloc function. So it is implementation depended, whether the
199 * returned sstr_t.ptr pointer must be passed to the allocators
200 * ucx_allocator_free function manually.
201 *
202 * The sstr_t.ptr of the return value will <i>always</i> be <code>NULL</code>-
203 * terminated.
204 *
205 * @param allocator a valid instance of an UcxAllocator
206 * @param string the string to duplicate
207 * @return a duplicate of the string
208 */
209 sstr_t sstrdupa(UcxAllocator *allocator, sstr_t string);
210
211 /**
212 * Omits leading and trailing spaces.
213 *
214 * This function returns a new sstr_t containing a trimmed version of the
215 * specified string.
216 *
217 * <b>Note:</b> the new sstr_t references the same memory, thus you
218 * <b>MUST NOT</b> pass the sstr_t.ptr of the return value to
219 * <code>free()</code>. It is also highly recommended to avoid assignments like
220 * <code>mystr = sstrtrim(mystr);</code> as you lose the reference to the
221 * source string. Assignments of this type are only permitted, if the
222 * sstr_t.ptr of the source string does not need to be freed or if another
223 * reference to the source string exists.
224 *
225 * @param string the string that shall be trimmed
226 * @return a new sstr_t containing the trimmed string
227 */
192 sstr_t sstrtrim(sstr_t string); 228 sstr_t sstrtrim(sstr_t string);
193 229
194 #ifdef __cplusplus 230 #ifdef __cplusplus
195 } 231 }
196 #endif 232 #endif

mercurial