summaryrefslogtreecommitdiff
path: root/ext/dl/handle.c
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-25 00:11:15 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-25 00:11:15 +0000
commit60f86b2edbabb25cdce5ae0898a50f8edfc8a143 (patch)
tree292697f25ece9d734bd890f607bb5d36e628e7dd /ext/dl/handle.c
parentc30de1e38e8d5ff633ebe90e110c5acdaa79f583 (diff)
* ext/dl/handle.c (rb_dlhandle_sym) refactoring rb_secure(2)
* test/dl/test_handle.rb (**) testing sym behavior git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/handle.c')
-rw-r--r--ext/dl/handle.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/dl/handle.c b/ext/dl/handle.c
index ad1f2210cf..0b78565cef 100644
--- a/ext/dl/handle.c
+++ b/ext/dl/handle.c
@@ -218,8 +218,6 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
{
struct dl_handle *dlhandle;
- rb_secure(2);
-
TypedData_Get_Struct(self, struct dl_handle, &dlhandle_data_type, dlhandle);
if( ! dlhandle->open ){
rb_raise(rb_eDLError, "closed handle");
@@ -235,16 +233,26 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
#define RTLD_DEFAULT NULL
#endif
+/*
+ * Document-method: sym
+ * Document-method: []
+ *
+ * call-seq: sym(name)
+ *
+ * Get the address as an Integer for the function named +name+. The function
+ * is searched via dlsym on RTLD_NEXT. See man(3) dlsym() for more info.
+ */
VALUE
rb_dlhandle_s_sym(VALUE self, VALUE sym)
{
- rb_secure(2);
return dlhandle_sym(RTLD_NEXT, StringValueCStr(sym));
}
static VALUE
dlhandle_sym(void *handle, const char *name)
{
+ rb_secure(2);
+
#if defined(HAVE_DLERROR)
const char *err;
# define CHECK_DLERROR if( err = dlerror() ){ func = 0; }