Changeset 560d79f in mainline
- Timestamp:
- 2012-03-02T14:50:25Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 76f382b
- Parents:
- 0030eef
- Location:
- uspace/lib/c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/str.c
r0030eef r560d79f 259 259 260 260 return offset; 261 } 262 263 /** Get size of string with size limit. 264 * 265 * Get the number of bytes which are used by the string @a str 266 * (excluding the NULL-terminator), but no more than @max_size bytes. 267 * 268 * @param str String to consider. 269 * @param max_size Maximum number of bytes to measure. 270 * 271 * @return Number of bytes used by the string 272 * 273 */ 274 size_t str_nsize(const char *str, size_t max_size) 275 { 276 size_t size = 0; 277 278 while ((*str++ != 0) && (size < max_size)) 279 size++; 280 281 return size; 282 } 283 284 /** Get size of wide string with size limit. 285 * 286 * Get the number of bytes which are used by the wide string @a str 287 * (excluding the NULL-terminator), but no more than @max_size bytes. 288 * 289 * @param str Wide string to consider. 290 * @param max_size Maximum number of bytes to measure. 291 * 292 * @return Number of bytes used by the wide string 293 * 294 */ 295 size_t wstr_nsize(const wchar_t *str, size_t max_size) 296 { 297 return (wstr_nlength(str, max_size) * sizeof(wchar_t)); 261 298 } 262 299 -
uspace/lib/c/include/str.h
r0030eef r560d79f 60 60 extern size_t str_size(const char *str); 61 61 extern size_t wstr_size(const wchar_t *str); 62 63 extern size_t str_nsize(const char *str, size_t max_size); 64 extern size_t wstr_nsize(const wchar_t *str, size_t max_size); 62 65 63 66 extern size_t str_lsize(const char *str, size_t max_len);
Note:
See TracChangeset
for help on using the changeset viewer.