mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-04-30 19:09:26 +08:00
Fix GCC warning for strncpy
This commit is contained in:
parent
1b80804c4a
commit
6eb3481855
@ -30,9 +30,8 @@ char *mystrdup(const char *s) {
|
||||
#ifdef CHAISCRIPT_MSVC
|
||||
strcpy_s(d, len + 1, s); // Copy the characters
|
||||
#else
|
||||
strncpy(d, s, len); // Copy the characters
|
||||
strncpy(d, s, len + 1); // Copy the characters
|
||||
#endif
|
||||
*std::next(d, static_cast<std::ptrdiff_t>(len)) = '\0';
|
||||
return d; // Return the new string
|
||||
}
|
||||
|
||||
|
||||
@ -35,9 +35,8 @@ char *mystrdup(const char *s) {
|
||||
#ifdef CHAISCRIPT_MSVC
|
||||
strcpy_s(d, len + 1, s); // Copy the characters
|
||||
#else
|
||||
strncpy(d, s, len); // Copy the characters
|
||||
strncpy(d, s, len + 1); // Copy the characters
|
||||
#endif
|
||||
d[len] = '\0';
|
||||
return d; // Return the new string
|
||||
}
|
||||
|
||||
|
||||
@ -35,9 +35,8 @@ char *mystrdup(const char *s) {
|
||||
#ifdef CHAISCRIPT_MSVC
|
||||
strcpy_s(d, len + 1, s); // Copy the characters
|
||||
#else
|
||||
strncpy(d, s, len); // Copy the characters
|
||||
strncpy(d, s, len + 1); // Copy the characters
|
||||
#endif
|
||||
*std::next(d, static_cast<std::ptrdiff_t>(len)) = '\0';
|
||||
return d; // Return the new string
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user