Method: Fiddle::CStructEntity#initialize
- Defined in:
- lib/fiddle/struct.rb
#initialize(addr, types, func = nil) ⇒ CStructEntity
Wraps the C pointer addr as a C struct with the given types.
When the instance is garbage collected, the C function func is called.
See also Fiddle::Pointer.new
353 354 355 356 357 358 359 |
# File 'lib/fiddle/struct.rb', line 353 def initialize(addr, types, func = nil) if func && addr.is_a?(Pointer) && addr.free raise ArgumentError, 'free function specified on both underlying struct Pointer and when creating a CStructEntity - who do you want to free this?' end set_ctypes(types) super(addr, @size, func) end |