diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-06-16 12:29:02 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-06-16 12:29:02 +0400 |
commit | c9341334b17db0df98c9f01142fc954e77962823 (patch) | |
tree | 83cf6c74122d51d27d3af70a2f89de8361b8eb54 /source/blender/blenlib | |
parent | fcc4251c07c6bc4ca5a121d224d40d3655af9a03 (diff) |
add BLI_strcpy_rlen, replace strcat, which was used in misleading way.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_string.h | 7 | ||||
-rw-r--r-- | source/blender/blenlib/intern/string.c | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 770a4c0e3ab..c6f0bc49c9b 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -72,6 +72,13 @@ __attribute__((nonnull)) #endif ; +size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +__attribute__((nonnull)) +#endif +; + char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix) #ifdef __GNUC__ __attribute__((warn_unused_result)) diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index aba73936975..9d811aba503 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -139,6 +139,13 @@ size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, const return srclen; } +size_t BLI_strcpy_rlen(char *__restrict dst, const char *__restrict src) +{ + size_t srclen = strlen(src); + memcpy(dst, src, srclen + 1); + return srclen; +} + /** * Portable replacement for #vsnprintf */ |