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
12
ext/dl/ptr.c
12
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 ){
|
if( TYPE(key) == T_FIXNUM || TYPE(key) == T_BIGNUM ){
|
||||||
void *dst, *src;
|
void *dst, *src;
|
||||||
int len;
|
long len;
|
||||||
|
|
||||||
StringValue(val);
|
StringValue(val);
|
||||||
Data_Get_Struct(self, struct ptr_data, data);
|
Data_Get_Struct(self, struct ptr_data, data);
|
||||||
dst = (void*)((long)(data->ptr) + DLNUM2LONG(key));
|
dst = (void*)((long)(data->ptr) + DLNUM2LONG(key));
|
||||||
src = RSTRING(val)->ptr;
|
src = RSTRING(val)->ptr;
|
||||||
|
len = RSTRING(val)->len;
|
||||||
if( num == Qnil ){
|
if( num == Qnil ){
|
||||||
len = RSTRING(val)->len;
|
memcpy(dst, src, len);
|
||||||
}
|
}
|
||||||
else{
|
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;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue