summaryrefslogtreecommitdiffstats
path: root/lib/efl/eina_hash.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-05-01 09:13:08 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-05-01 09:13:08 +0200
commitf95e9909e93dd1ddb9d19ccd36be34a3a84ddd44 (patch)
tree8a9db1f0f59e6e898db12deb6943a9c44aa8bf8a /lib/efl/eina_hash.rb
parentbb7b6c52a50e65fb361ede8f26039b5822b9a0cb (diff)
downloadffi-efl-f95e9909e93dd1ddb9d19ccd36be34a3a84ddd44.zip
ffi-efl-f95e9909e93dd1ddb9d19ccd36be34a3a84ddd44.tar.gz
fix AutoPointer usage + use it for REinaHash
Diffstat (limited to 'lib/efl/eina_hash.rb')
-rw-r--r--lib/efl/eina_hash.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/efl/eina_hash.rb b/lib/efl/eina_hash.rb
index e47e2c1..9aa8808 100644
--- a/lib/efl/eina_hash.rb
+++ b/lib/efl/eina_hash.rb
@@ -26,20 +26,17 @@ module Efl
@ptr = (
case o
when NilClass
- cstr.call
-# FFI::AutoPointer.new cstr.call, method(:free)
+ FFI::AutoPointer.new cstr.call, method(:free)
when self.class
o.to_ptr
-# when FFI::AutoPointer
-# o
+ when FFI::AutoPointer
+ o
when FFI::Pointer
- ( o==FFI::Pointer::NULL ? cstr.call : o )
-# FFI::AutoPointer.new ( o==FFI::Pointer::NULL ? cstr.call : o ), method(:free)
+ FFI::AutoPointer.new ( o==FFI::Pointer::NULL ? cstr.call : o ), method(:free)
when Hash
ptr = cstr.call
o.each do |k,v| Efl::EinaHash.eina_hash_add ptr, k, v end
- ptr
-# FFI::AutoPointer.new ptr, method(:free)
+ FFI::AutoPointer.new ptr, method(:free)
else
raise ArgumentError.new "wrong argument #{o.class.name}"
end
@@ -48,6 +45,7 @@ module Efl
def free p=nil
return Efl::EinaHash.eina_hash_free p unless p.nil?
Efl::EinaHash.eina_hash_free @ptr
+ @ptr.free
@ptr = nil
end
def each data=FFI::Pointer::NULL, &block