diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2013-01-20 08:03:45 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2013-01-20 08:03:45 +0100 |
commit | f4d99cb9244f277fa66c0b797681a85ac4598476 (patch) | |
tree | bb5be72fb8c278cae73a2aaca761e42aad0eab7c | |
parent | 793988e7f6992404681efbc23c0eb8f0d14c2dc3 (diff) | |
download | gmp-f4d99cb9244f277fa66c0b797681a85ac4598476.tar.gz |
mini-gmp/mini-gmp.c (mpz_init_set_str): New function.
-rw-r--r-- | mini-gmp/mini-gmp.c | 7 | ||||
-rw-r--r-- | mini-gmp/mini-gmp.h | 3 | ||||
-rw-r--r-- | mini-gmp/tests/t-str.c | 5 |
3 files changed, 11 insertions, 4 deletions
diff --git a/mini-gmp/mini-gmp.c b/mini-gmp/mini-gmp.c index 21806f326..5d16d76f1 100644 --- a/mini-gmp/mini-gmp.c +++ b/mini-gmp/mini-gmp.c @@ -3946,6 +3946,13 @@ mpz_set_str (mpz_t r, const char *sp, int base) return 0; } +int +mpz_init_set_str (mpz_t r, const char *sp, int base) +{ + mpz_init (r); + return mpz_set_str (r, sp, base); +} + size_t mpz_out_str (FILE *stream, int base, const mpz_t x) { diff --git a/mini-gmp/mini-gmp.h b/mini-gmp/mini-gmp.h index 5b2453953..edcaa7555 100644 --- a/mini-gmp/mini-gmp.h +++ b/mini-gmp/mini-gmp.h @@ -1,6 +1,6 @@ /* mini-gmp, a minimalistic implementation of a GNU GMP subset. -Copyright 2011, 2012 Free Software Foundation, Inc. +Copyright 2011, 2012, 2013 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -223,6 +223,7 @@ void mpz_init_set_d (mpz_t, double); size_t mpz_sizeinbase (const mpz_t, int); char *mpz_get_str (char *, int, const mpz_t); int mpz_set_str (mpz_t, const char *, int); +int mpz_init_set_str (mpz_t, const char *, int); /* This long list taken from gmp.h. */ /* For reference, "defined(EOF)" cannot be used here. In g++ 2.95.4, diff --git a/mini-gmp/tests/t-str.c b/mini-gmp/tests/t-str.c index 93f251971..8d7a0bca3 100644 --- a/mini-gmp/tests/t-str.c +++ b/mini-gmp/tests/t-str.c @@ -89,12 +89,11 @@ test_small (void) }; unsigned i; mpz_t a, b; - mpz_init (a); mpz_init (b); for (i = 0; data[i].input; i++) { - int res = mpz_set_str (a, data[i].input, 0); + int res = mpz_init_set_str (a, data[i].input, 0); if (data[i].decimal) { if (res != 0) @@ -125,9 +124,9 @@ test_small (void) res, data[i].input); abort (); } + mpz_clear (a); } - mpz_clear (a); mpz_clear (b); } |