Mercurial > dropbear
comparison libtommath/bn_mp_mod.c @ 608:4fbf9a7556ed
Use mp_init_size() to avoid some mp_grow()s
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 18 Mar 2011 14:31:07 +0000 |
parents | 5ff8218bcee9 |
children | 60fc6476e044 |
comparison
equal
deleted
inserted
replaced
607:aa2f51a6b81d | 608:4fbf9a7556ed |
---|---|
20 mp_mod (mp_int * a, mp_int * b, mp_int * c) | 20 mp_mod (mp_int * a, mp_int * b, mp_int * c) |
21 { | 21 { |
22 mp_int t; | 22 mp_int t; |
23 int res; | 23 int res; |
24 | 24 |
25 if ((res = mp_init (&t)) != MP_OKAY) { | 25 if ((res = mp_init_size (&t, b->used)) != MP_OKAY) { |
26 return res; | 26 return res; |
27 } | 27 } |
28 | 28 |
29 if ((res = mp_div (a, b, NULL, &t)) != MP_OKAY) { | 29 if ((res = mp_div (a, b, NULL, &t)) != MP_OKAY) { |
30 mp_clear (&t); | 30 mp_clear (&t); |