don't use memcpy for non-trivial structures

master
Daniel Kolesa 2021-03-18 01:37:38 +01:00
parent 6ed9ae1235
commit 7023e09049
2 changed files with 4 additions and 2 deletions

View File

@ -15,7 +15,6 @@
#include <ostd/platform.hh>
#include <ostd/string.hh>
#include <ostd/range.hh>
#include <ostd/io.hh>
#include <ostd/format.hh>
namespace cscript {

View File

@ -2,6 +2,7 @@
#include "cs_vm.hh"
#include "cs_util.hh"
#include <ostd/io.hh>
#include <limits>
namespace cscript {
@ -1644,7 +1645,9 @@ void cs_state::run(cs_ident *id, cs_value_r args, cs_value &ret) {
case cs_ident_type::Command:
if (nargs < static_cast<cs_command *>(id)->get_num_args()) {
cs_valarray<cs_value, MaxArguments> buf{*this};
memcpy(&buf[0], &args[0], args.size() * sizeof(cs_value));
for (std::size_t i = 0; i < args.size(); ++i) {
buf[i] = args[i];
}
callcommand(
*this, static_cast<cs_command *>(id), &buf[0], ret,
nargs, false