Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The clone method of Fiddle::CStruct object is shallow copy #66

Open
kojix2 opened this issue Jan 29, 2021 · 0 comments · May be fixed by #67
Open

The clone method of Fiddle::CStruct object is shallow copy #66

kojix2 opened this issue Jan 29, 2021 · 0 comments · May be fixed by #67

Comments

@kojix2
Copy link
Contributor

kojix2 commented Jan 29, 2021

Fiddle

require 'fiddle/import'

S = Fiddle::Importer.struct(["int i"])

a = S.malloc

a.i = 10

b = a.clone

b.i = 20

p a.i # 20
p b.i # 20

Ruby-FFI

require 'ffi'

class S < FFI::Struct
  layout :i, :int
end

a = S.new

a[:i] = 10

b = a.clone

b[:i] = 20

p a[:i] # 10
p b[:i] # 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant