Move hexpatch to Rust

This commit is contained in:
topjohnwu
2023-06-20 18:17:26 -07:00
parent 5805573625
commit 399b9e5eba
13 changed files with 78 additions and 39 deletions
+10 -2
View File
@@ -32,8 +32,8 @@ void byte_data::swap(byte_data &o) {
std::swap(_sz, o._sz);
}
vector<size_t> byte_data::patch(byte_view from, byte_view to) {
vector<size_t> v;
rust::Vec<size_t> byte_data::patch(byte_view from, byte_view to) {
rust::Vec<size_t> v;
if (_buf == nullptr)
return v;
auto p = _buf;
@@ -50,6 +50,14 @@ vector<size_t> byte_data::patch(byte_view from, byte_view to) {
return v;
}
rust::Vec<size_t> mut_u8_patch(
rust::Slice<uint8_t> buf,
rust::Slice<const uint8_t> from,
rust::Slice<const uint8_t> to) {
byte_data data(buf);
return data.patch(from, to);
}
int fork_dont_care() {
if (int pid = xfork()) {
waitpid(pid, nullptr, 0);