Listing 3 Code using goto to consolidate error-handling code

    int SomeFunc(void)
        {
        char    *buf1,  *buf2,  *buf3;
        int     ccode;
        if ((buf1 = malloc(1024)) == NULL)
            {
            ccode = -1;
            goto End1;
            }
        if ((buf2 = malloc(1024)) == NULL)
            {
            ccode = -1;
            goto End2;
            }
        if ((buf3 = malloc(1024)) == NULL)
            {
            ccode = -1;
            goto End3;
            }
        //   More code here
End3:
        free(buf3);
End2:
        free(buf2);
End1:
        free(buf1);
        return(ccode);
        }

/* End of File */