summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/efl/ecore_evas.rb1
-rw-r--r--lib/efl/eina_hash.rb14
-rw-r--r--lib/efl/evas.rb1
-rw-r--r--spec/eina_hash_spec.rb6
4 files changed, 8 insertions, 14 deletions
diff --git a/lib/efl/ecore_evas.rb b/lib/efl/ecore_evas.rb
index 6dadd3f..cb08d30 100644
--- a/lib/efl/ecore_evas.rb
+++ b/lib/efl/ecore_evas.rb
@@ -30,6 +30,7 @@ module Efl
def free p=nil
return Efl::EcoreEvas.ecore_evas_free p unless p.nil?
Efl::EcoreEvas.ecore_evas_free @ptr
+ @ptr.free
@ptr=nil
end
def get
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
diff --git a/lib/efl/evas.rb b/lib/efl/evas.rb
index 56657d3..3713e6b 100644
--- a/lib/efl/evas.rb
+++ b/lib/efl/evas.rb
@@ -124,6 +124,7 @@ module Efl
def free p=nil
return Efl::Evas.evas_object_del p unless p.nil?
Efl::Evas.evas_object_del @ptr
+ @ptr.free
@ptr=nil
end
def geometry_get
diff --git a/spec/eina_hash_spec.rb b/spec/eina_hash_spec.rb
index 5efc062..8473fd7 100644
--- a/spec/eina_hash_spec.rb
+++ b/spec/eina_hash_spec.rb
@@ -33,7 +33,6 @@ describe Efl::EinaHash do
v.read_string.empty?.should be_false
}
cpt.should eql 4
- h.free
end
#
it "should be able to convert into ruby Hash from NULL pointer" do
@@ -86,7 +85,6 @@ describe Efl::EinaHash do
rh2['k1'].should eql 'D1'
rh2['k2'].should eql 'D2'
rh2['k3'].should eql 'D3'
- h.free
end
#
it "should be able to convert into ruby Hash from non empty REinaHash pointer" do
@@ -105,7 +103,6 @@ describe Efl::EinaHash do
h['k3'].read_string.should eql "D3"
rh = Hash.from_eina_hash h.to_ptr
rh.length.should eql 4
- h.free
end
#
it "should be able to convert into ruby Hash from non empty REinaHash pointer, with key from string" do
@@ -128,7 +125,6 @@ describe Efl::EinaHash do
rh['k1'].read_string.should eql "D1"
rh['k2'].read_string.should eql "D2"
rh['k3'].read_string.should eql "D3"
- h.free
end
#
it "should be able to convert into ruby Hash from non empty REinaHash pointer, with key from string block" do
@@ -153,7 +149,6 @@ describe Efl::EinaHash do
rh['k1'].read_string.should eql "D1"
rh['k2'].read_string.should eql "D2"
rh['k3'].read_string.should eql "D3"
- h.free
end
#
it "should be able to build from ruby Hash" do
@@ -175,7 +170,6 @@ describe Efl::EinaHash do
h[k1].read_string.should eql "D1"
h[k2].read_string.should eql "D2"
h[k3].read_string.should eql "D3"
- h.free
end
#
it "alternate constructor should work" do