From eec91057b827013a3e02c51b60e46c8597295132 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 8 Apr 2014 23:11:00 +0100 Subject: [PATCH] py: Add comment mpz function, and free memory used for string printing. --- py/mpz.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/py/mpz.c b/py/mpz.c index a6b024ca87..b42e96ee18 100644 --- a/py/mpz.c +++ b/py/mpz.c @@ -1255,7 +1255,7 @@ uint mpz_as_str_inpl(const mpz_t *i, uint base, const char *prefix, char base_ch return s - str; } - // make a copy of mpz digits + // make a copy of mpz digits, so we can do the div/mod calculation mpz_dig_t *dig = m_new(mpz_dig_t, ilen); memcpy(dig, i->dig, ilen * sizeof(mpz_dig_t)); @@ -1295,6 +1295,9 @@ uint mpz_as_str_inpl(const mpz_t *i, uint base, const char *prefix, char base_ch } while (!done); + // free the copy of the digits array + m_del(mpz_dig_t, dig, ilen); + if (prefix) { const char *p = &prefix[strlen(prefix)]; while (p > prefix) {