Skip to content

Commit

Permalink
Simplify FFI memory write
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Jan 21, 2025
1 parent ceee1ff commit e90e1f7
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/lffi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,8 @@ static int ffi_push_new (lua_State *L, int i) {
luaL_error(L, "no member with name '%s'", memname.c_str());
}
const soup::rflType& type = strct->getMemberType(memname);
uint64_t data = *reinterpret_cast<uint64_t*>(reinterpret_cast<uintptr_t>(udata) + offset);
uint64_t new_data = check_ffi_value(L, 3, rfl_type_to_ffi_type(type));
memcpy(&data, &new_data, type.getSize());
*reinterpret_cast<uint64_t*>(reinterpret_cast<uintptr_t>(udata) + offset) = data;
memcpy(reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(udata) + offset), &new_data, type.getSize());
}
return 0;
});
Expand Down

0 comments on commit e90e1f7

Please sign in to comment.