From 76fe0008a254b2d4f752f6a27951e1d17d3ac100 Mon Sep 17 00:00:00 2001 From: ramkumarkoppu Date: Sun, 19 May 2013 20:04:26 +0200 Subject: [PATCH] Update bn_mp_init_copy.c In mp_init_copy(), mp_init() is used to assign the memory with default block size, mp_copy() is used to grow the target mp_int size if it is required and copy the content. My suggestion is to use mp_init_size() instead of mp_init() inside the mp_init_copy to assign required memory depending on the source mp_int size and then use mp_copy to copy the content. This will avoid the subsequent mp_grow() inside the mp_copy(). The associated issue number is 11 in GitHub. --- bn_mp_init_copy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bn_mp_init_copy.c b/bn_mp_init_copy.c index ed58c16..ab87d23 100644 --- a/bn_mp_init_copy.c +++ b/bn_mp_init_copy.c @@ -20,7 +20,7 @@ int mp_init_copy (mp_int * a, mp_int * b) { int res; - if ((res = mp_init (a)) != MP_OKAY) { + if ((res = mp_init_size (a, b->used)) != MP_OKAY) { return res; } return mp_copy (b, a);