mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Merged Nakada's patch [ruby-dev:18097].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
40bc4f5ae4
commit
ee9f1463df
1 changed files with 7 additions and 5 deletions
10
ext/dl/ptr.c
10
ext/dl/ptr.c
|
@ -858,19 +858,21 @@ rb_dlptr_aset(int argc, VALUE argv[], VALUE self)
|
|||
|
||||
if( TYPE(key) == T_FIXNUM || TYPE(key) == T_BIGNUM ){
|
||||
void *dst, *src;
|
||||
int len;
|
||||
long len;
|
||||
|
||||
StringValue(val);
|
||||
Data_Get_Struct(self, struct ptr_data, data);
|
||||
dst = (void*)((long)(data->ptr) + DLNUM2LONG(key));
|
||||
src = RSTRING(val)->ptr;
|
||||
len = RSTRING(val)->len;
|
||||
if( num == Qnil ){
|
||||
len = RSTRING(val)->len;
|
||||
memcpy(dst, src, len);
|
||||
}
|
||||
else{
|
||||
len = NUM2INT(num);
|
||||
long n = NUM2INT(num);
|
||||
memcpy(dst, src, n < len ? n : len);
|
||||
if( n > len ) MEMZERO((char*)dst + len, char, n - len);
|
||||
};
|
||||
memcpy(dst, src, len);
|
||||
return val;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue