[Gmp-commit] /var/hg/gmp: 2 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Wed Nov 12 16:24:13 UTC 2014
details: /var/hg/gmp/rev/ec7d9f2087c5
changeset: 16508:ec7d9f2087c5
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Wed Nov 12 17:22:40 2014 +0100
description:
mini-gmp: a handfull of casts on pointers
details: /var/hg/gmp/rev/48b3df21c477
changeset: 16509:48b3df21c477
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Wed Nov 12 17:23:59 2014 +0100
description:
gen-fib.c: cast malloc'd pointer
diffstat:
gen-fib.c | 2 +-
mini-gmp/mini-gmp.c | 12 ++++++------
mini-gmp/tests/t-str.c | 4 ++--
mini-gmp/tests/testutils.c | 8 ++++----
4 files changed, 13 insertions(+), 13 deletions(-)
diffs (125 lines):
diff -r b7561e428ff1 -r 48b3df21c477 gen-fib.c
--- a/gen-fib.c Mon Nov 10 00:55:28 2014 +0100
+++ b/gen-fib.c Wed Nov 12 17:23:59 2014 +0100
@@ -45,7 +45,7 @@
/* fib(2n) > 2^n, so use 2n as a limit for the table size */
falloc = 2 * numb_bits;
- f = xmalloc (falloc * sizeof (*f));
+ f = (mpz_t*) xmalloc (falloc * sizeof (*f));
mpz_init_set_ui (f[0], 1L); /* F[-1] */
mpz_init_set_ui (f[1], 0L); /* F[0] */
diff -r b7561e428ff1 -r 48b3df21c477 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c Mon Nov 10 00:55:28 2014 +0100
+++ b/mini-gmp/mini-gmp.c Wed Nov 12 17:23:59 2014 +0100
@@ -264,7 +264,7 @@
static void *
gmp_default_realloc (void *old, size_t old_size, size_t new_size)
{
- mp_ptr p;
+ void * p;
p = realloc (old, new_size);
@@ -322,14 +322,14 @@
static mp_ptr
gmp_xalloc_limbs (mp_size_t size)
{
- return gmp_xalloc (size * sizeof (mp_limb_t));
+ return (mp_ptr) gmp_xalloc (size * sizeof (mp_limb_t));
}
static mp_ptr
gmp_xrealloc_limbs (mp_ptr old, mp_size_t size)
{
assert (size > 0);
- return (*gmp_reallocate_func) (old, 0, size * sizeof (mp_limb_t));
+ return (mp_ptr) (*gmp_reallocate_func) (old, 0, size * sizeof (mp_limb_t));
}
@@ -1383,7 +1383,7 @@
gmp_free (r->_mp_d);
}
-static void *
+static mp_ptr
mpz_realloc (mpz_t r, mp_size_t size)
{
size = GMP_MAX (size, 1);
@@ -4049,7 +4049,7 @@
sn = 1 + mpz_sizeinbase (u, base);
if (!sp)
- sp = gmp_xalloc (1 + sn);
+ sp = (char *) gmp_xalloc (1 + sn);
un = GMP_ABS (u->_mp_size);
@@ -4131,7 +4131,7 @@
}
sn = strlen (sp);
- dp = gmp_xalloc (sn + (sn == 0));
+ dp = (unsigned char *) gmp_xalloc (sn + (sn == 0));
for (sn = 0; *sp; sp++)
{
diff -r b7561e428ff1 -r 48b3df21c477 mini-gmp/tests/t-str.c
--- a/mini-gmp/tests/t-str.c Mon Nov 10 00:55:28 2014 +0100
+++ b/mini-gmp/tests/t-str.c Wed Nov 12 17:23:59 2014 +0100
@@ -243,7 +243,7 @@
assert (tn <= MAXLIMBS);
mpn_copyi (t, a->_mp_d, tn);
- bn = mpn_get_str (bp, base, t, tn);
+ bn = mpn_get_str ((unsigned char *) bp, base, t, tn);
if (bn != arn)
{
fprintf (stderr, "mpn_get_str failed:\n");
@@ -286,7 +286,7 @@
abort ();
}
}
- tn = mpn_set_str (t, bp, bn, base);
+ tn = mpn_set_str (t, (unsigned char *) bp, bn, base);
if (tn != mpz_size (a) || mpn_cmp (t, a->_mp_d, tn))
{
fprintf (stderr, "mpn_set_str failed:\n");
diff -r b7561e428ff1 -r 48b3df21c477 mini-gmp/tests/testutils.c
--- a/mini-gmp/tests/testutils.c Mon Nov 10 00:55:28 2014 +0100
+++ b/mini-gmp/tests/testutils.c Wed Nov 12 17:23:59 2014 +0100
@@ -53,12 +53,12 @@
/* Check small redzone, return pointer to malloced block. */
static size_t *
-block_check (char *p)
+block_check (void *p)
{
size_t *block = (size_t *) p - 1;
size_t size = block[0];
- if (memcmp (p + size, block_end, sizeof(block_end)) != 0)
+ if (memcmp ((char *)p + size, block_end, sizeof(block_end)) != 0)
{
fprintf (stderr, "red zone overwritten.\n");
abort ();
@@ -70,7 +70,7 @@
static void *
tu_alloc (size_t size)
{
- size_t *block = malloc (sizeof(size_t) + size + sizeof(block_end));
+ size_t *block = (size_t *) malloc (sizeof(size_t) + size + sizeof(block_end));
if (!block)
{
fprintf (stderr, "Virtual memory exhausted.\n");
@@ -84,7 +84,7 @@
tu_realloc (void *p, size_t old_size, size_t new_size)
{
size_t *block = block_check (p);
- block = realloc (block, sizeof(size_t) + new_size + sizeof(block_end));
+ block = (size_t *) realloc (block, sizeof(size_t) + new_size + sizeof(block_end));
if (!block)
{
fprintf (stderr, "Virtual memory exhausted.\n");
More information about the gmp-commit
mailing list