summaryrefslogtreecommitdiff
path: root/test/fiddle/test_c_struct_entry.rb
diff options
context:
space:
mode:
authorChris Seaton <chris@chrisseaton.com>2020-05-19 00:12:47 +0100
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-05-23 14:34:07 +0900
commit3015a7aae7ddc9b63149df34b1f12366e07a9563 (patch)
treed8717bceae57a47f2257f8701c02423d51dab62f /test/fiddle/test_c_struct_entry.rb
parent24b615e82ee327a9ac583937de746ba12dde2d6a (diff)
downloadruby-3015a7aae7ddc9b63149df34b1f12366e07a9563.tar.gz
[ruby/fiddle] Improve documentation on how to correctly free memory and free memory in tests (#33)
https://github.com/ruby/fiddle/commit/e59cfd708a
Diffstat (limited to 'test/fiddle/test_c_struct_entry.rb')
-rw-r--r--test/fiddle/test_c_struct_entry.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/fiddle/test_c_struct_entry.rb b/test/fiddle/test_c_struct_entry.rb
index 8ece438f54..33bfee6218 100644
--- a/test/fiddle/test_c_struct_entry.rb
+++ b/test/fiddle/test_c_struct_entry.rb
@@ -43,7 +43,7 @@ module Fiddle
end
def test_set_ctypes
- union = CStructEntity.malloc [TYPE_INT, TYPE_LONG]
+ union = CStructEntity.malloc [TYPE_INT, TYPE_LONG], Fiddle::RUBY_FREE
union.assign_names %w[int long]
# this test is roundabout because the stored ctypes are not accessible
@@ -55,20 +55,20 @@ module Fiddle
end
def test_aref_pointer_array
- team = CStructEntity.malloc([[TYPE_VOIDP, 2]])
+ team = CStructEntity.malloc([[TYPE_VOIDP, 2]], Fiddle::RUBY_FREE)
team.assign_names(["names"])
- alice = Fiddle::Pointer.malloc(6)
+ alice = Fiddle::Pointer.malloc(6, Fiddle::RUBY_FREE)
alice[0, 6] = "Alice\0"
- bob = Fiddle::Pointer.malloc(4)
+ bob = Fiddle::Pointer.malloc(4, Fiddle::RUBY_FREE)
bob[0, 4] = "Bob\0"
team["names"] = [alice, bob]
assert_equal(["Alice", "Bob"], team["names"].map(&:to_s))
end
def test_aref_pointer
- user = CStructEntity.malloc([TYPE_VOIDP])
+ user = CStructEntity.malloc([TYPE_VOIDP], Fiddle::RUBY_FREE)
user.assign_names(["name"])
- alice = Fiddle::Pointer.malloc(6)
+ alice = Fiddle::Pointer.malloc(6, Fiddle::RUBY_FREE)
alice[0, 6] = "Alice\0"
user["name"] = alice
assert_equal("Alice", user["name"].to_s)