Skip to content

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

Description

@kojix2

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions