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:
ttate 2002-08-29 13:00:22 +00:00
parent 40bc4f5ae4
commit ee9f1463df
1 changed files with 7 additions and 5 deletions

View File

@ -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;
if( num == Qnil ){
len = RSTRING(val)->len; len = RSTRING(val)->len;
if( num == Qnil ){
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;
}; };