diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-14 13:49:20 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-14 13:49:20 +0400 |
commit | 4dcd4e1a289af0afc0a35bc304a858af804620c4 (patch) | |
tree | 9041868b6936a824e89f4a4a1bb3e97f880f7394 /source/blender/blenlib | |
parent | 1158f06b5783613083ccc0a9d02eb53de1d77e56 (diff) |
minor change to BLI_strncpy(). replace strlen() with BLI_strnlen().
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/string.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 08d4f8e1198..c03daa97e3c 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -71,13 +71,11 @@ char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2) char *BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) { - size_t srclen = strlen(src); - size_t cpylen = (srclen > (maxncpy - 1)) ? (maxncpy - 1) : srclen; + size_t srclen = BLI_strnlen(src, maxncpy - 1); BLI_assert(maxncpy != 0); - - memcpy(dst, src, cpylen); - dst[cpylen] = '\0'; - + + memcpy(dst, src, srclen); + dst[srclen] = '\0'; return dst; } |