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)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user