1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
ttate 2002-05-20 15:35:48 +00:00
parent a2db8e72c1
commit 4bf76b4e6c
6 changed files with 29 additions and 20 deletions

View file

@ -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.

View file

@ -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

View file

@ -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);

View file

@ -81,7 +81,7 @@ module DL
return mem
end
def alloc(size = nil)
def malloc(size = nil)
if( !size )
size = @size
end

View file

@ -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_new(dlmalloc((size_t)size), size, func);
return rb_dlptr_new2(rb_cDLPtrData, ptr, size, func);
}
VALUE
rb_dlptr_malloc(long size, freefunc_t 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);

View file

@ -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)