One way would be to make the user responsible for allocation of the result as well [and thus, no hidden deallocation or other problems with "numbers getting overwritten".
Using a 3-argument add function would do the trick:
Code:
void add(bigint a, bigint b, bigint c)
{
// a = b + c [or c = a + b].
}
However, you then need to accept calls like this:
Code:
bigint x = make_bigint();
bigint y = make_bigint();
add(x, x, y);
add(y, x, y);
add(x, x, x);
But it avoids the allocation of memory that isn't being freed because the pointer is being "lost" in the operation.
--
Mats