Class: LIBUSB::Call::Transfer

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/libusb/call.rb

Instance Method Summary collapse

Constructor Details

#initializeTransfer

Returns a new instance of Transfer.



553
554
555
556
557
558
559
560
561
562
563
564
565
566
# File 'lib/libusb/call.rb', line 553

def initialize(*)
  super

  ptr = pointer
  def ptr.free_struct(id)
    Call.libusb_free_transfer(self)
    return unless @ctx
    @ctx.unref_context
  end
  # The ctx pointer is not yet assigned.
  # It happens at LIBUSB::Transfer#dev_handle= later on.
  ptr.instance_variable_set(:@ctx, nil)
  ObjectSpace.define_finalizer(self, ptr.method(:free_struct))
end