aboutsummaryrefslogtreecommitdiff
path: root/py/objint_mpz.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-10-11 13:11:32 +1100
committerDamien George <damien.p.george@gmail.com>2016-10-11 13:11:32 +1100
commit8bb7d958f173eec58892bc00115516c160f93243 (patch)
tree6e17bda1e05c52ef8d627c3ca253055bce895a1f /py/objint_mpz.c
parentdf3e5d2b2f8610d246fea348bb96e70f636183ea (diff)
py: Factor duplicated function to calculate size of formatted int.
Diffstat (limited to 'py/objint_mpz.c')
-rw-r--r--py/objint_mpz.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/py/objint_mpz.c b/py/objint_mpz.c
index 3a30eb9d9..137d514de 100644
--- a/py/objint_mpz.c
+++ b/py/objint_mpz.c
@@ -95,7 +95,7 @@ char *mp_obj_int_formatted_impl(char **buf, mp_uint_t *buf_size, mp_uint_t *fmt_
assert(MP_OBJ_IS_TYPE(self_in, &mp_type_int));
const mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in);
- mp_uint_t needed_size = mpz_as_str_size(&self->mpz, base, prefix, comma);
+ mp_uint_t needed_size = mp_int_format_size(mpz_max_num_bits(&self->mpz), base, prefix, comma);
if (needed_size > *buf_size) {
*buf = m_new(char, needed_size);
*buf_size = needed_size;