Use memcpy for string conversion

pull/117/head
A. R. Shajii 2022-12-13 11:23:26 -05:00
parent f093d9578d
commit cfbe6f6ec1
1 changed files with 4 additions and 3 deletions
codon/runtime

View File

@ -237,9 +237,10 @@ SEQ_FUNC void seq_gc_exclude_static_roots(void *start, void *end) {
* String conversion * String conversion
*/ */
static seq_str_t string_conv(const std::string &s) { static seq_str_t string_conv(const std::string &s) {
auto *p = (char *)seq_alloc_atomic(s.size()); auto n = s.size();
strncpy(p, s.c_str(), s.size()); auto *p = (char *)seq_alloc_atomic(n);
return {(seq_int_t)s.size(), p}; memcpy(p, s.data(), n);
return {(seq_int_t)n, p};
} }
template <typename T> std::string default_format(T n) { template <typename T> std::string default_format(T n) {