mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-12-26 12:17:32 +00:00
Improve strcpy_trunc
Zero all remaining array
This commit is contained in:
parent
caef52e3b3
commit
a797b350a0
@ -13,7 +13,7 @@ inline void strcpy_trunc(char (&dst)[N], const std::string& src)
|
||||
{
|
||||
const std::size_t count = src.size() >= N ? N - 1 : src.size();
|
||||
std::memcpy(dst, src.c_str(), count);
|
||||
dst[count] = '\0';
|
||||
std::memset(dst + count, 0, N - count);
|
||||
}
|
||||
|
||||
// Copy null-terminated string from char array to another char array with truncation
|
||||
@ -22,7 +22,7 @@ inline void strcpy_trunc(char (&dst)[N], const char (&src)[N2])
|
||||
{
|
||||
const std::size_t count = N2 >= N ? N - 1 : N2;
|
||||
std::memcpy(dst, src, count);
|
||||
dst[count] = '\0';
|
||||
std::memset(dst + count, 0, N - count);
|
||||
}
|
||||
|
||||
template <std::size_t N>
|
||||
|
Loading…
Reference in New Issue
Block a user