mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Edit the documentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cd948e4600
commit
66484faf1b
1 changed files with 7 additions and 2 deletions
|
@ -47,12 +47,17 @@ 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 the timeval structure.
|
||||||
"long tv_sec",
|
"long tv_sec",
|
||||||
"long tv_uses",
|
"long tv_uses",
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
val = LIBC::Timeval.new # allocate the memory.
|
val = LIBC::Timeval.alloc # allocate the memory.
|
||||||
|
|
||||||
|
The above example uses LIBC::Timeval.alloc, since we use LIBC::Timeval.new(ptr)
|
||||||
|
to wrap the given PtrData object which is, for example, created by DL::malloc().
|
||||||
|
DL::malloc() is a function to allocate a memory by using the C library function
|
||||||
|
malloc().
|
||||||
|
|
||||||
DL::Importable module is very useful. However, we sometimes encounter a case
|
DL::Importable module is very useful. However, we sometimes encounter a case
|
||||||
that we must directly use low-level functions such as dlsym(). In such case,
|
that we must directly use low-level functions such as dlsym(). In such case,
|
||||||
|
|
Loading…
Reference in a new issue