Improve the description.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
71c41cf5a5
commit
0c767620cd
@ -47,17 +47,16 @@ struct and union which are defined in "dl/struct.rb" as follows:
|
|||||||
require "dl/struct"
|
require "dl/struct"
|
||||||
module LIBC
|
module LIBC
|
||||||
extend DL::Importable
|
extend DL::Importable
|
||||||
Timeval = struct [ # define the timeval structure.
|
Timeval = struct [ # define timeval structure.
|
||||||
"long tv_sec",
|
"long tv_sec",
|
||||||
"long tv_uses",
|
"long tv_uses",
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
val = LIBC::Timeval.malloc # allocate the memory.
|
val = LIBC::Timeval.malloc # allocate memory.
|
||||||
|
|
||||||
The above example uses LIBC::Timeval.malloc, since we use LIBC::Timeval.new(ptr)
|
Notice that the above example takes LIBC::Timeval.malloc to allocate memory,
|
||||||
to wrap the given PtrData object which is, for example, created by DL::malloc().
|
rather than LIBC::Timeval.new. It is because DL::Timeval.new is for wrapping
|
||||||
DL::malloc() is a function to allocate a memory by using the C library function
|
an object, PtrData, which has already been created.
|
||||||
malloc().
|
|
||||||
|
|
||||||
We can define a callback using the module function "callback" as follows:
|
We can define a callback using the module function "callback" as follows:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user