Will the logger cause a leak memory?

function()

pointer structInitialization = malloc (sizeof());

if( )
blah blah ; // this essentially gets the values of the struct

else

logger (exception ) ;

elementOFStruct = something.struct;
free(structInitialization);
return elementOfStruct;


Will this leak memory if the else statement (logger) is hit? If so how would I go about making sure the memory gets freed?
Last edited on
My apologies for the confusion, I am just using malloc or calloc to allocate memory the struct pointer.

Essentially I am asking if the function goes to the logger exception, will it skip the freeing of the structure allocated memory by malloc/calloc? If so how so I resolve this issue?
Essentially I am asking if the function goes to the logger exception, will it skip the freeing of the structure allocated memory by malloc/calloc?

If the code structure you've shown is accurate, it will not skip free.
Topic archived. No new replies allowed.