mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/dl/cptr.c (rb_dlptr_s_malloc, rb_dlptr_initialize): adding
documentation * test/dl/test_cptr.rb (**): testing that malloc works when passed free functions git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5296367cf4
commit
bc52ea0fde
2 changed files with 35 additions and 0 deletions
|
@ -3,6 +3,22 @@ require_relative '../ruby/envutil'
|
|||
|
||||
module DL
|
||||
class TestCPtr < TestBase
|
||||
def test_malloc_free_func_int
|
||||
free = CFunc.new(@libc['free'], TYPE_VOID, 'free')
|
||||
|
||||
ptr = CPtr.malloc(10, free.to_i)
|
||||
assert_equal 10, ptr.size
|
||||
assert_equal free.to_i, ptr.free.to_i
|
||||
end
|
||||
|
||||
def test_malloc_free_func
|
||||
free = CFunc.new(@libc['free'], TYPE_VOID, 'free')
|
||||
|
||||
ptr = CPtr.malloc(10, free)
|
||||
assert_equal 10, ptr.size
|
||||
assert_equal free.to_i, ptr.free.to_i
|
||||
end
|
||||
|
||||
def test_to_str
|
||||
str = "hello world"
|
||||
ptr = CPtr[str]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue