summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-05-20 15:35:48 +0000
committerttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-05-20 15:35:48 +0000
commit4bf76b4e6c85db9177f1501843b8161ddfae222b (patch)
tree08d6ffce3fc185927152eed8281407a1f3862826
parenta2db8e72c10c5e5506f18314ac805cd8206a4181 (diff)
rename PtrData::alloc and Struct#alloc to malloc respectively.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--ext/dl/dl.c8
-rw-r--r--ext/dl/dl.h3
-rw-r--r--ext/dl/lib/dl/struct.rb2
-rw-r--r--ext/dl/ptr.c26
-rw-r--r--ext/dl/sample/libc.rb4
6 files changed, 29 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 8301f6c9fa6..20a120150b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue May 21 00:20:25 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
+
+ * ext/dl/ptr.c: rename PtrData::alloc to PtrData::malloc.
+
+ * ext/dl/lib/dl/struct.c: rename Struct#alloc to Struct#malloc.
+
Mon May 20 13:28:52 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* io.c (rb_io_clone): writing stream was not copied properly.
diff --git a/ext/dl/dl.c b/ext/dl/dl.c
index cb370ae2523..99df0ba193f 100644
--- a/ext/dl/dl.c
+++ b/ext/dl/dl.c
@@ -457,13 +457,7 @@ rb_dl_dlopen(int argc, VALUE argv[], VALUE self)
VALUE
rb_dl_malloc(VALUE self, VALUE size)
{
- void *ptr;
- long s;
-
- s = DLNUM2LONG(size);
- ptr = dlmalloc((size_t)s);
- memset(ptr,0,(size_t)s);
- return rb_dlptr_new(ptr, s, dlfree);
+ return rb_dlptr_malloc(DLNUM2LONG(size), dlfree);
}
VALUE
diff --git a/ext/dl/dl.h b/ext/dl/dl.h
index bfe83087cdc..9554ea91ba0 100644
--- a/ext/dl/dl.h
+++ b/ext/dl/dl.h
@@ -296,7 +296,8 @@ void dlptr_free(struct ptr_data *data);
void dlptr_init(VALUE val);
VALUE rb_dlptr_new(void *ptr, long size, freefunc_t func);
-VALUE rb_dlptr_alloc(long size, freefunc_t func);
+VALUE rb_dlptr_new2(VALUE klass, void *ptr, long size, freefunc_t func);
+VALUE rb_dlptr_malloc(long size, freefunc_t func);
void *rb_dlptr2cptr(VALUE val);
VALUE rb_dlsym_new(void (*func)(), const char *name, const char *type);
diff --git a/ext/dl/lib/dl/struct.rb b/ext/dl/lib/dl/struct.rb
index faa1377c511..efa9118c115 100644
--- a/ext/dl/lib/dl/struct.rb
+++ b/ext/dl/lib/dl/struct.rb
@@ -81,7 +81,7 @@ module DL
return mem
end
- def alloc(size = nil)
+ def malloc(size = nil)
if( !size )
size = @size
end
diff --git a/ext/dl/ptr.c b/ext/dl/ptr.c
index a6af30112dc..60b7f71860b 100644
--- a/ext/dl/ptr.c
+++ b/ext/dl/ptr.c
@@ -83,7 +83,7 @@ dlptr_init(VALUE val)
}
VALUE
-rb_dlptr_new(void *ptr, long size, freefunc_t func)
+rb_dlptr_new2(VALUE klass, void *ptr, long size, freefunc_t func)
{
struct ptr_data *data;
VALUE val;
@@ -91,7 +91,7 @@ rb_dlptr_new(void *ptr, long size, freefunc_t func)
if( ptr ){
val = rb_dlmem_aref(ptr);
if( val == Qnil ){
- val = Data_Make_Struct(rb_cDLPtrData, struct ptr_data,
+ val = Data_Make_Struct(klass, struct ptr_data,
0, dlptr_free, data);
data->ptr = ptr;
data->free = func;
@@ -119,9 +119,19 @@ rb_dlptr_new(void *ptr, long size, freefunc_t func)
}
VALUE
-rb_dlptr_alloc(long size, freefunc_t func)
+rb_dlptr_new(void *ptr, long size, freefunc_t func)
+{
+ return rb_dlptr_new2(rb_cDLPtrData, ptr, size, func);
+}
+
+VALUE
+rb_dlptr_malloc(long size, freefunc_t func)
{
- return rb_dlptr_new(dlmalloc((size_t)size), size, func);
+ void *ptr;
+
+ ptr = dlmalloc((size_t)size);
+ memset(ptr,0,(size_t)size);
+ return rb_dlptr_new(ptr, size, func);
}
void *
@@ -177,7 +187,7 @@ rb_dlptr_s_new(int argc, VALUE argv[], VALUE klass)
}
static VALUE
-rb_dlptr_s_alloc(int argc, VALUE argv[], VALUE klass)
+rb_dlptr_s_malloc(int argc, VALUE argv[], VALUE klass)
{
VALUE size, sym, obj;
int s;
@@ -195,9 +205,7 @@ rb_dlptr_s_alloc(int argc, VALUE argv[], VALUE klass)
rb_bug("rb_dlptr_s_new");
};
- obj = rb_dlptr_alloc(s,f);
-
- rb_obj_call_init(obj, argc, argv);
+ obj = rb_dlptr_malloc(s,f);
return obj;
}
@@ -996,7 +1004,7 @@ Init_dlptr()
{
rb_cDLPtrData = rb_define_class_under(rb_mDL, "PtrData", rb_cData);
rb_define_singleton_method(rb_cDLPtrData, "new", rb_dlptr_s_new, -1);
- rb_define_singleton_method(rb_cDLPtrData, "alloc", rb_dlptr_s_alloc, -1);
+ rb_define_singleton_method(rb_cDLPtrData, "malloc", rb_dlptr_s_malloc, -1);
rb_define_method(rb_cDLPtrData, "initialize", rb_dlptr_init, -1);
rb_define_method(rb_cDLPtrData, "free=", rb_dlptr_free_set, 1);
rb_define_method(rb_cDLPtrData, "free", rb_dlptr_free_get, 0);
diff --git a/ext/dl/sample/libc.rb b/ext/dl/sample/libc.rb
index cb16aa043fd..7d1de2601d6 100644
--- a/ext/dl/sample/libc.rb
+++ b/ext/dl/sample/libc.rb
@@ -57,8 +57,8 @@ ptr = ary.to_ptr
LIBC.qsort(ptr, ary.length, DL.sizeof('P'), $cb1)
p ptr.to_a('S', ary.length)
-tv = LIBC::Timeval.alloc
-tz = LIBC::Timezone.alloc
+tv = LIBC::Timeval.malloc
+tz = LIBC::Timezone.malloc
LIBC.gettimeofday(tv, tz)
p Time.at(tv.tv_sec)