Another problem (was Re: Error returns and repeated code, GOTOs, etc.)



On May 29, 11:44 pm, mike3 <mike4...@xxxxxxxxx> wrote:
<snip>

I've also noticed another problem. I've got a place where a
routine needs to _return_ a BigNum it mints inside itself.

ErrorCode MyFunc(BigNum **OutputValue)
{
...
*OutputValue = (BigNum *)malloc(sizeof(BigNum));
if(*OutputValue == NULL)
{
<duplicated err handler>
}

rv = BigNum_Initialize(*OutputValue);
if(rv != ERROR_SUCCESS)
{
<ditto>
}

...
(error handlers in here that now have to _free the alloced
memory
and not just deinit the BigNum_! What should I do about
this?)
...
}

What to do?
.



Relevant Pages