summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-06 22:50:05 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-06 22:50:05 +0000
commit90e410088e44ff0239ffd8c990f085d74a1a2b5c (patch)
tree1cf8b274c54fd6ef83fcf10a01cad44110848ade /ext
parent105461551ff0abc6531486cabba413e62dd2e622 (diff)
downloadruby-90e410088e44ff0239ffd8c990f085d74a1a2b5c.tar.gz
ruby-90e410088e44ff0239ffd8c990f085d74a1a2b5c.tar.xz
ruby-90e410088e44ff0239ffd8c990f085d74a1a2b5c.zip
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@25678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/dl/cptr.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c
index a5b07edc7..0c85a91b6 100644
--- a/ext/dl/cptr.c
+++ b/ext/dl/cptr.c
@@ -123,6 +123,15 @@ rb_dlptr_s_allocate(VALUE klass)
return obj;
}
+/*
+ * call-seq:
+ * DL::CPtr.new(address) => dl_cptr
+ * DL::CPtr.new(address, size) => dl_cptr
+ * DL::CPtr.new(address, size, freefunc) => dl_cptr
+ *
+ * Create a new pointer to +address+ with an optional +size+ and +freefunc+.
+ * +freefunc+ will be called when the instance is garbage collected.
+ */
static VALUE
rb_dlptr_initialize(int argc, VALUE argv[], VALUE self)
{
@@ -163,6 +172,16 @@ rb_dlptr_initialize(int argc, VALUE argv[], VALUE self)
return Qnil;
}
+/*
+ * call-seq:
+ *
+ * DL::CPtr.malloc(size, freefunc = nil) => dl cptr instance
+ *
+ * Allocate +size+ bytes of memory and associate it with an optional
+ * +freefunc+ that will be called when the pointer is garbage collected.
+ * +freefunc+ must be an address pointing to a function or an instance of
+ * DL::CFunc
+ */
static VALUE
rb_dlptr_s_malloc(int argc, VALUE argv[], VALUE klass)
{