mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* util.c (ruby_strdup, Balloc, rv_alloc): use size_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1f17d739ce
commit
24ccacfafd
2 changed files with 22 additions and 12 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sat Mar 14 14:16:02 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* util.c (ruby_strdup, Balloc, rv_alloc): use size_t.
|
||||||
|
|
||||||
Sat Mar 14 13:53:11 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Mar 14 13:53:11 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* util.c (ruby_qsort): the result of cmp must be signed, so ge
|
* util.c (ruby_qsort): the result of cmp must be signed, so ge
|
||||||
|
|
30
util.c
30
util.c
|
@ -33,7 +33,7 @@ ruby_scan_oct(const char *start, int len, int *retlen)
|
||||||
retval <<= 3;
|
retval <<= 3;
|
||||||
retval |= *s++ - '0';
|
retval |= *s++ - '0';
|
||||||
}
|
}
|
||||||
*retlen = s - start;
|
*retlen = (int)(s - start); /* less than len */
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,14 +43,14 @@ ruby_scan_hex(const char *start, int len, int *retlen)
|
||||||
static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
|
static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
|
||||||
register const char *s = start;
|
register const char *s = start;
|
||||||
register unsigned long retval = 0;
|
register unsigned long retval = 0;
|
||||||
char *tmp;
|
const char *tmp;
|
||||||
|
|
||||||
while (len-- && *s && (tmp = strchr(hexdigit, *s))) {
|
while (len-- && *s && (tmp = strchr(hexdigit, *s))) {
|
||||||
retval <<= 4;
|
retval <<= 4;
|
||||||
retval |= (tmp - hexdigit) & 15;
|
retval |= (tmp - hexdigit) & 15;
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
*retlen = s - start;
|
*retlen = (int)(s - start); /* less than len */
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +590,7 @@ char *
|
||||||
ruby_strdup(const char *str)
|
ruby_strdup(const char *str)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int len = strlen(str) + 1;
|
size_t len = strlen(str) + 1;
|
||||||
|
|
||||||
tmp = xmalloc(len);
|
tmp = xmalloc(len);
|
||||||
memcpy(tmp, str, len);
|
memcpy(tmp, str, len);
|
||||||
|
@ -898,6 +898,9 @@ static double private_mem[PRIVATE_mem], *pmem_next = private_mem;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#if 0
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + defined(IBM) != 1
|
#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + defined(IBM) != 1
|
||||||
|
@ -1124,7 +1127,7 @@ Balloc(int k)
|
||||||
int x;
|
int x;
|
||||||
Bigint *rv;
|
Bigint *rv;
|
||||||
#ifndef Omit_Private_Memory
|
#ifndef Omit_Private_Memory
|
||||||
unsigned int len;
|
size_t len;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ACQUIRE_DTOA_LOCK(0);
|
ACQUIRE_DTOA_LOCK(0);
|
||||||
|
@ -1190,7 +1193,7 @@ multadd(Bigint *b, int m, int a) /* multiply by m and add a */
|
||||||
#ifdef ULLong
|
#ifdef ULLong
|
||||||
y = *x * (ULLong)m + carry;
|
y = *x * (ULLong)m + carry;
|
||||||
carry = y >> 32;
|
carry = y >> 32;
|
||||||
*x++ = (ULong)y & FFFFFFFF;
|
*x++ = (ULong)(y & FFFFFFFF);
|
||||||
#else
|
#else
|
||||||
#ifdef Pack_32
|
#ifdef Pack_32
|
||||||
xi = *x;
|
xi = *x;
|
||||||
|
@ -1379,7 +1382,7 @@ mult(Bigint *a, Bigint *b)
|
||||||
do {
|
do {
|
||||||
z = *x++ * (ULLong)y + *xc + carry;
|
z = *x++ * (ULLong)y + *xc + carry;
|
||||||
carry = z >> 32;
|
carry = z >> 32;
|
||||||
*xc++ = (ULong)z & FFFFFFFF;
|
*xc++ = (ULong)(z & FFFFFFFF);
|
||||||
} while (x < xae);
|
} while (x < xae);
|
||||||
*xc = (ULong)carry;
|
*xc = (ULong)carry;
|
||||||
}
|
}
|
||||||
|
@ -1617,12 +1620,12 @@ diff(Bigint *a, Bigint *b)
|
||||||
do {
|
do {
|
||||||
y = (ULLong)*xa++ - *xb++ - borrow;
|
y = (ULLong)*xa++ - *xb++ - borrow;
|
||||||
borrow = y >> 32 & (ULong)1;
|
borrow = y >> 32 & (ULong)1;
|
||||||
*xc++ = (ULong)y & FFFFFFFF;
|
*xc++ = (ULong)(y & FFFFFFFF);
|
||||||
} while (xb < xbe);
|
} while (xb < xbe);
|
||||||
while (xa < xae) {
|
while (xa < xae) {
|
||||||
y = *xa++ - borrow;
|
y = *xa++ - borrow;
|
||||||
borrow = y >> 32 & (ULong)1;
|
borrow = y >> 32 & (ULong)1;
|
||||||
*xc++ = (ULong)y & FFFFFFFF;
|
*xc++ = (ULong)(y & FFFFFFFF);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#ifdef Pack_32
|
#ifdef Pack_32
|
||||||
|
@ -2980,7 +2983,7 @@ quorem(Bigint *b, Bigint *S)
|
||||||
carry = ys >> 32;
|
carry = ys >> 32;
|
||||||
y = *bx - (ys & FFFFFFFF) - borrow;
|
y = *bx - (ys & FFFFFFFF) - borrow;
|
||||||
borrow = y >> 32 & (ULong)1;
|
borrow = y >> 32 & (ULong)1;
|
||||||
*bx++ = (ULong)y & FFFFFFFF;
|
*bx++ = (ULong)(y & FFFFFFFF);
|
||||||
#else
|
#else
|
||||||
#ifdef Pack_32
|
#ifdef Pack_32
|
||||||
si = *sx++;
|
si = *sx++;
|
||||||
|
@ -3020,7 +3023,7 @@ quorem(Bigint *b, Bigint *S)
|
||||||
carry = ys >> 32;
|
carry = ys >> 32;
|
||||||
y = *bx - (ys & FFFFFFFF) - borrow;
|
y = *bx - (ys & FFFFFFFF) - borrow;
|
||||||
borrow = y >> 32 & (ULong)1;
|
borrow = y >> 32 & (ULong)1;
|
||||||
*bx++ = (ULong)y & FFFFFFFF;
|
*bx++ = (ULong)(y & FFFFFFFF);
|
||||||
#else
|
#else
|
||||||
#ifdef Pack_32
|
#ifdef Pack_32
|
||||||
si = *sx++;
|
si = *sx++;
|
||||||
|
@ -3067,7 +3070,7 @@ rv_alloc(int i)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
nrv_alloc(const char *s, char **rve, int n)
|
nrv_alloc(const char *s, char **rve, size_t n)
|
||||||
{
|
{
|
||||||
char *rv, *t;
|
char *rv, *t;
|
||||||
|
|
||||||
|
@ -3819,5 +3822,8 @@ ruby_each_words(const char *str, void (*func)(const char*, int, void*), void *ar
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue