diff options
author | Ton Roosendaal <ton@blender.org> | 2010-02-27 18:39:13 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2010-02-27 18:39:13 +0300 |
commit | 7fca47e0cf3ca0d520bacc8f079f4e33d4521b71 (patch) | |
tree | c50bd2733043696c45b791d2e77390cc000bc05b /source/blender/blenlib/intern/string.c | |
parent | c76b6fcb06c45f0e018a6c8a892f380099a2371a (diff) |
fix in commit today using strnlen, which is only available for gcc.
This adds a BLI_strnlen() to the blenlib.
Patch provided by Sergey Sharybin (nazgul)
Diffstat (limited to 'source/blender/blenlib/intern/string.c')
-rw-r--r-- | source/blender/blenlib/intern/string.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index bf2e1d28b3a..dd1d0a3bd4f 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -342,3 +342,10 @@ void BLI_timestr(double _time, char *str) str[11]=0; } + +/* determine the length of a fixed-size string */ +size_t BLI_strnlen(const char *str, size_t maxlen) +{ + const char *end = memchr(str, '\0', maxlen); + return end ? (size_t) (end - str) : maxlen; +} |