Subject:
[ruby-ffi] Is the release interface supposed to swallow errors?
From:
Daniel Berger
Date:
10/8/13 10:52 AM
To:
ruby-ffi@googlegroups.com

Hi,

ffi 1.9.0

I noticed that if I declare a struct using .auto_ptr, that the corresponding release method seems to swallow errors.

require 'ffi'

class Solaris
  extend FFI::Library
  ffi_lib :kstat

  class KstatCtl < FFI::Struct
    layout(:kc_chain_id, :int, :kc_chain, :pointer, :kc_kd, :int)

    def self.release(pointer)
      puts "Releasing..." # Yep, I see this
      bogus # Shouldn't this raise an error? Instead, nothing happens.
    end
  end

  attach_function :kstat_open, [], KstatCtl.auto_ptr
  attach_function :kstat_close, [KstatCtl], :int

  def self.kstat
    kptr = kstat_open()
    kstat_close(kptr)
  end
end

Solaris.kstat

What I'm really trying to do is have the release method call kstat_close inside the KstatCtl's release method. It fails, but I can't tell -why- it fails since the error is getting swallowed.

Help or advice appreciated.

Regards,

Dan

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.