I have some functions that can cause memory leaks. For example doing something like:
I end up losing the old allocated space in a without freeing it. Any suggestions as to how best to deal with this?Code:typedef struct
{
Uint32 *part;
Uint16 size;
}bigint;
bigint add(bigint a, bigint b)
{
// Do something
return result;
}
int main()
{
bigint a = make_bigint(); // Memory allocated here
bigint b = make_bigint();
a = add(a, b); // old allocation lost here
}