Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenlib/intern/BLI_dynstr.c2
-rw-r--r--source/blender/blenlib/intern/string.c7
2 files changed, 8 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c
index 09d28ddbc3a..4b7b61e64d9 100644
--- a/source/blender/blenlib/intern/BLI_dynstr.c
+++ b/source/blender/blenlib/intern/BLI_dynstr.c
@@ -85,7 +85,7 @@ void BLI_dynstr_append(DynStr *ds, const char *cstr) {
void BLI_dynstr_nappend(DynStr *ds, const char *cstr, int len) {
DynStrElem *dse= malloc(sizeof(*dse));
- int cstrlen= strnlen(cstr, len);
+ int cstrlen= BLI_strnlen(cstr, len);
dse->str= malloc(cstrlen+1);
memcpy(dse->str, cstr, cstrlen);
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;
+}