This blogpost is horrible! The title is good, you can tell if someone actually uses C at a decent level based off of if they describe SESE(single exit single entry) and how you use goto's to achieve that.
BUT, the fact they have multiple goto locations in one function violates this! Only one goto locations ! That goto is goto cleanup, or goto exit. What you do is then check state of each variable you cleanup. Every function should be some variable of this. If anyone writes C in any other style than SESE, you can consider them a subpar C programmer. There's variations like using BOOL and in and out variables. I like them, but there are different styles. But anyone not using a single AND ONLY A SINGLE goto in every function is 100% a subpar C programmer who you should not trust.
BOOL foo()
{
int *allocation;
char *allocation2;
BOOL bRet = FALSE;
const int BUFFSIZE = 10; //NO MAGIC NUMBERS
allocation = resourceallocation(BUFFSIZE); // Malloc, file.open, network open, etc
if(!allocation)
{
DEBUGPRINT("ALLOCAITON FAILED");
bRet = FALSE; //Redundent, but protect against intern
goto cleanup;
}
allocation2 = resourceallocation2(BUFFSIZE); // Malloc, file.open, network open, etc
if(!allocation2)
{
DEBUGPRINT("ALLOCAITON FAILED");
bRet = FALSE; //Redundent, but protect against intern
goto cleanup;
}
...
bRet = TRUE;
cleanup:
//Add error handling if allocation fails
if(allocation)
resourcefree(allocation);
if(allocation2)
resourcefree(allocation2);
return bRet;
}