Permalink
Browse files

freeing value gotten seems to reduce memleak

  • Loading branch information...
1 parent 9361bd6 commit caaaa1fc87be7f072d5ad8fae04a2d1f9a9ba7c5 @jmettraux committed Dec 24, 2009
@@ -66,6 +66,8 @@ class << self
#
attfunc :tcfree, [ :pointer ], :void
+ attfunc :free, [ :pointer ], :void
+
#
# tcadb functions
#
@@ -63,11 +63,14 @@ def outlen_op (method, *args)
return nil if out.address == 0
- return out.get_bytes(0, outlen.get_int(0))
+ out.get_bytes(0, outlen.get_int(0))
ensure
outlen.free
+
+ #clib.free(out)
+ # uncommenting that wreaks havoc
end
end
@@ -37,9 +37,13 @@ def outlen_op (method, *args)
out = lib.send(method, *args)
return nil if out.address == 0
- return out.get_bytes(0, outlen.get_int(0))
+
+ out.get_bytes(0, outlen.get_int(0))
+
ensure
outlen.free
+ #lib.tcfree(out)
+ lib.free(out)
end
end
end
@@ -54,6 +54,8 @@ class << self
alias :attfunc :attach_function
end
+ attfunc :free, [ :pointer ], :void
+
# http://1978th.net/tokyotyrant/spex.html#tcrdbapi
#
@@ -31,7 +31,7 @@
@db.getdup('a').should.equal([ 'a0', 'a1' ])
end
-
+
it 'should be able to fetch keys for duplicate values' do
[ %w[John Hornbeck],
%w[Tim Gourley],
@@ -58,11 +58,11 @@
end
describe 'Rufus::Tokyo::Cabinet .tcb order' do
-
+
before do
FileUtils.rm(DB_FILE) if File.exist? DB_FILE
end
-
+
it 'should default to a lexical order' do
db = Rufus::Tokyo::Cabinet.new(DB_FILE)
@@ -85,8 +85,8 @@
db.close
end
- #
+ #
# It's not possible to call tcbdbsetcmpfunc() through the abstract API, so
# changing comparison functions are only supported through the Edo interface.
- #
+ #
end

0 comments on commit caaaa1f

Please sign in to comment.