I have been trying to free memory allocated via malloc() using free().
Some of the structs it does free but leaves some the way they were and they also remain linked to their children. It also never frees the root (gRootPtr) for a binary tree.
I am using Xcode to find out if the memory used by the binary tree has been freed and also use the if statement.
Code I am using to free the memory:
void FreeMemory(InfoDefiner *InfoCarrier)
{
    if ((*InfoCarrier) != NULL) {
        FreeMemory((&(*InfoCarrier)->left));
        FreeMemory((&(*InfoCarrier)->right));
        free((*InfoCarrier));
    }
}
Code I am using to see if the memory has been freed.
if (gRootPtr != NULL) {
    return 1;
}
else{
    return 0;
}
 
     
     
     
     
    