mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
* internal.h (struct RBignum): Use size_t for len.
* include/ruby/intern.h (rb_big_new): Use size_t instead of long to specify the size of bignum. (rb_big_resize): Ditto. * bignum.c: Follow above changes. * rational.c: Follow above changes. * marshal.c: Follow above changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8233f969a2
commit
95de2b0012
6 changed files with 51 additions and 26 deletions
14
marshal.c
14
marshal.c
|
@ -35,8 +35,8 @@
|
|||
#if SIZEOF_SHORT == SIZEOF_BDIGIT
|
||||
#define SHORTLEN(x) (x)
|
||||
#else
|
||||
static long
|
||||
shortlen(long len, BDIGIT *ds)
|
||||
static size_t
|
||||
shortlen(size_t len, BDIGIT *ds)
|
||||
{
|
||||
BDIGIT num;
|
||||
int offset = 0;
|
||||
|
@ -774,11 +774,17 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
|
|||
w_byte(TYPE_BIGNUM, arg);
|
||||
{
|
||||
char sign = BIGNUM_SIGN(obj) ? '+' : '-';
|
||||
long len = BIGNUM_LEN(obj);
|
||||
size_t len = BIGNUM_LEN(obj);
|
||||
size_t slen;
|
||||
BDIGIT *d = BIGNUM_DIGITS(obj);
|
||||
|
||||
slen = SHORTLEN(len);
|
||||
if (LONG_MAX < slen) {
|
||||
rb_raise(rb_eTypeError, "too big Bignum can't be dumped");
|
||||
}
|
||||
|
||||
w_byte(sign, arg);
|
||||
w_long(SHORTLEN(len), arg); /* w_short? */
|
||||
w_long((long)slen, arg);
|
||||
while (len--) {
|
||||
#if SIZEOF_BDIGIT > SIZEOF_SHORT
|
||||
BDIGIT num = *d;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue