diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-09-04 09:30:57 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-09-04 09:31:53 -0700 |
commit | 1d84e6523250ab6d14f40fba3922c56d7a40416f (patch) | |
tree | 74155ea37e750ad19bc327fb3165b2cfd9440573 /src/bignum.c | |
parent | fe042e9d15da7863b5beb4c2cc326a62d2c7fccb (diff) | |
download | emacs-1d84e6523250ab6d14f40fba3922c56d7a40416f.tar.gz |
Fix bignum initialization
Problem reported by Andy Moreton in:
https://lists.gnu.org/r/emacs-devel/2018-09/msg00072.html
and crystal-ball diagnosis by Eli Zaretskii in:
https://lists.gnu.org/r/emacs-devel/2018-09/msg00075.html
* src/alloc.c (xrealloc_for_gmp, xfree_for_gmp): Move to bignum.c.
(init_alloc): Move bignum initialization to init_bignum.
* src/bignum.c (init_bignum): Rename from init_bignum_once.
All users changed.
* src/emacs.c (main): Call init_bignum after init_alloc,
instead of calling init_bignum_once after init_bignum.
Diffstat (limited to 'src/bignum.c')
-rw-r--r-- | src/bignum.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/bignum.c b/src/bignum.c index 2ce7412d06c..35894f5647d 100644 --- a/src/bignum.c +++ b/src/bignum.c @@ -34,9 +34,25 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ mpz_t mpz[4]; +static void * +xrealloc_for_gmp (void *ptr, size_t ignore, size_t size) +{ + return xrealloc (ptr, size); +} + +static void +xfree_for_gmp (void *ptr, size_t ignore) +{ + xfree (ptr); +} + void -init_bignum_once (void) +init_bignum (void) { + eassert (mp_bits_per_limb == GMP_NUMB_BITS); + integer_width = 1 << 16; + mp_set_memory_functions (xmalloc, xrealloc_for_gmp, xfree_for_gmp); + for (int i = 0; i < ARRAYELTS (mpz); i++) mpz_init (mpz[i]); } |