Skip to content

Commit

Permalink
serdata_print: fix windows
Browse files Browse the repository at this point in the history
  • Loading branch information
trittsv authored and eboasson committed Mar 22, 2024
1 parent 42f254a commit bae72f1
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/ddscxx/include/org/eclipse/cyclonedds/topic/datatopic.hpp
Expand Up @@ -634,14 +634,10 @@ size_t serdata_print(

const std::string data = ss.str();
const size_t len = data.size();
copy_len = len < bufsize ? len : bufsize;

copy_len = bufsize - 1;
if (len < bufsize) {
copy_len = len;
}

strncpy(buf, data.c_str(), copy_len);
buf[copy_len] = '\0'; // Null-terminate the string
std::copy_n(data.c_str(), copy_len, buf);
buf[len < bufsize ? copy_len : copy_len - 1] = '\0';
}

return copy_len;
Expand Down

0 comments on commit bae72f1

Please sign in to comment.