mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Implement strndup(3) using strnlen(3).
This makes the implementation a bit more consistent with strdup(3), which uses strlen(3).
This commit is contained in:
parent
62fd5fd625
commit
61d38d61e2
1 changed files with 1 additions and 3 deletions
|
|
@ -42,9 +42,7 @@ strndup(const char *str, size_t n)
|
|||
size_t len;
|
||||
char *copy;
|
||||
|
||||
for (len = 0; len < n && str[len]; len++)
|
||||
continue;
|
||||
|
||||
len = strnlen(str, n);
|
||||
if ((copy = malloc(len + 1)) == NULL)
|
||||
return (NULL);
|
||||
memcpy(copy, str, len);
|
||||
|
|
|
|||
Loading…
Reference in a new issue