[ox/model] Add support to SerStr for allocating string

This commit is contained in:
2020-04-16 22:21:59 -05:00
parent 8753d39b66
commit b3fa531aa0
5 changed files with 45 additions and 8 deletions

View File

@@ -12,6 +12,18 @@
#include "types.hpp"
#include "typetraits.hpp"
template<typename T1, typename T2>
constexpr char *ox_strcpy(T1 dest, T2 src) noexcept {
std::size_t i = 0;
while (src[i]) {
dest[i] = src[i];
++i;
}
// set null terminator
dest[i] = 0;
return dest;
}
template<typename T1, typename T2>
constexpr char *ox_strncpy(T1 dest, T2 src, std::size_t maxLen) noexcept {
std::size_t i = 0;