summaryrefslogtreecommitdiff
path: root/ext/dl/dl.c
diff options
context:
space:
mode:
authorttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-23 08:11:36 +0000
committerttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-23 08:11:36 +0000
commitc863d62b6f38f24bc2d61602e0a650e4710868cc (patch)
treeb3a369d820c63e82782b77ff4734a9a0d38a121c /ext/dl/dl.c
parentb04bb4fb26776f7e8558803ffd1cde67f9de637e (diff)
Merged Nakada-san's patch [ruby-core:02916].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/dl.c')
-rw-r--r--ext/dl/dl.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/ext/dl/dl.c b/ext/dl/dl.c
index 22abb754d23..676a0728127 100644
--- a/ext/dl/dl.c
+++ b/ext/dl/dl.c
@@ -1,3 +1,4 @@
+/* -*- mode: C; c-file-style: "gnu" -*-
/*
* $Id$
*/
@@ -164,9 +165,9 @@ dlsizeof(const char *cstr)
size = 0;
for (i=0; i<len; i++) {
n = 1;
- if (isdigit(cstr[i+1])) {
+ if (ISDIGIT(cstr[i+1])) {
dlen = 1;
- while (isdigit(cstr[i+dlen])) { dlen ++; };
+ while (ISDIGIT(cstr[i+dlen])) { dlen ++; };
dlen --;
d = ALLOCA_N(char, dlen + 1);
strncpy(d, cstr + i + 1, dlen);
@@ -563,8 +564,14 @@ rb_dl_malloc(VALUE self, VALUE size)
VALUE
rb_dl_strdup(VALUE self, VALUE str)
{
+ void *ptr;
+ long len;
+
SafeStringValue(str);
- return rb_dlptr_new(strdup(RSTRING(str)->ptr), RSTRING(str)->len, dlfree);
+ len = RSTRING(str)->len;
+ ptr = memcpy(dlmalloc(len + 1), RSTRING(str)->ptr, len + 1);
+ ((char *)ptr)[len] = '\0';
+ return rb_dlptr_new(ptr, len, dlfree);
}
static VALUE