Use std::memcpy instead of memcpy

This commit is contained in:
Twarit Waikar
2022-07-31 21:53:48 +05:30
parent 93c175cd1d
commit ff40154485
3 changed files with 6 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
#include <iostream>
#include <cstring>
#include "git_callbacks.h"
@@ -9,7 +10,7 @@ extern "C" int progress_cb(const char *str, int len, void *data) {
(void)data;
char *progress_str = new char[len + 1];
memcpy(progress_str, str, len);
std::memcpy(progress_str, str, len);
progress_str[len] = '\0';
std::cout << "remote: " << CString(godot::String(progress_str).strip_edges()).data << std::endl;
delete[] progress_str;

View File

@@ -1,5 +1,7 @@
#include "git_plugin.h"
#include <cstring>
#include "godot_cpp/core/class_db.hpp"
#include "godot_cpp/classes/file.hpp"
@@ -644,7 +646,7 @@ godot::Array GitPlugin::_parse_diff(git_diff *diff) {
GIT2_CALL_R(git_patch_get_line_in_hunk(&git_diff_line, patch.get(), j, k), "Could not get line from hunk in patch", godot::Array());
char *content = new char[git_diff_line->content_len + 1];
memcpy(content, git_diff_line->content, git_diff_line->content_len);
std::memcpy(content, git_diff_line->content, git_diff_line->content_len);
content[git_diff_line->content_len] = '\0';
godot::String status = " "; // We reserve 1 null terminated space to fill the + or the - character at git_diff_line->origin

View File

@@ -6,7 +6,7 @@ CString::CString(const godot::String &string) {
godot::CharString godot_char_str = string.utf8();
data = new char[godot_char_str.length() + 1];
memcpy(data, (void *)godot_char_str.get_data(), godot_char_str.length());
std::memcpy(data, (void *)godot_char_str.get_data(), godot_char_str.length());
data[godot_char_str.length()] = '\0';
}