mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-27 13:54:16 +01:00
[util] Add strlcpy helper
strncpy is not safe.
This commit is contained in:
parent
9ee0f51870
commit
dc6b7fa4a7
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
@ -39,5 +40,11 @@ namespace dxvk::str {
|
||||
format1(stream, args...);
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
inline void strlcpy(char* dst, const char* src, size_t count) {
|
||||
std::strncpy(dst, src, count);
|
||||
if (count > 0)
|
||||
dst[count - 1] = '\0';
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user