Typically, big-int views vary in length depending on the value presented; in general, the result will be longer than any of the operands. In particular, for multiplication, the size of the resulting representation is approximately the sum of the sizes of the arguments.
If you are sure that memory management is indeed a bottleneck for your particular platform, you might consider introducing a multiplication function that updates the third value. In terms of prototype C-style functions above:
void BigInt_Times_Update(const BigInt* a, const BigInt* b, BigInt* target);
This way you can handle memory management the same way C ++ std :: vector <> containers do: your update target needs to redistribute its heap data when the existing size is too small.
source share