If you take care to initialize the structure you allocate to zero (either explicitly or by using calloc
) then you can call your myADT_destroy
function on failure. The C specification explicitly allows free
to be called with a NULL
pointer.
Doing it that way, you can simplify the myADT_create
function substantially, and also creates some symmetry.