mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-08 23:44:00 +03:00
Code extracted from:
https://github.com/libuv/libuv.git
at commit f84c5e693b80cb0c62bcefba147e7a66e2b839c9 (v1.x).
18 lines
307 B
C
18 lines
307 B
C
#include "strscpy.h"
|
|
#include <limits.h> /* SSIZE_MAX */
|
|
|
|
ssize_t uv__strscpy(char* d, const char* s, size_t n) {
|
|
size_t i;
|
|
|
|
for (i = 0; i < n; i++)
|
|
if ('\0' == (d[i] = s[i]))
|
|
return i > SSIZE_MAX ? UV_E2BIG : (ssize_t) i;
|
|
|
|
if (i == 0)
|
|
return 0;
|
|
|
|
d[--i] = '\0';
|
|
|
|
return UV_E2BIG;
|
|
}
|