Changeset 98cb0495 in mainline for uspace/lib/c/generic/str.c


Ignore:
Timestamp:
2012-03-04T18:52:28Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
38b950f
Parents:
6561a8e (diff), 0499235 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/str.c

    r6561a8e r98cb0495  
    259259       
    260260        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 */
     274size_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 */
     295size_t wstr_nsize(const wchar_t *str, size_t max_size)
     296{
     297        return (wstr_nlength(str, max_size) * sizeof(wchar_t));
    261298}
    262299
Note: See TracChangeset for help on using the changeset viewer.