Created
April 10, 2015 07:17
-
-
Save Shinpeim/a6fe552af051800fd26d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// たとえばこんなかんじ | |
int nyan(){ | |
int *p1 = (int *)malloc(sizeof(int)) | |
int *p2 = (int *)malloc(sizeof(int)) | |
int *p3 = (int *)malloc(sizeof(int)) | |
int retval = 0; | |
// ごちゃごちゃなんかやる | |
//!エラーが起こった! | |
if (err) { | |
retval = -1; // エラーコードを入れて | |
goto cleanup; //cleanupにすっ飛ぶ | |
} | |
//正常系は続く | |
retval = 1; //正常系の場合の返り値を入れて | |
cleanup: | |
free(p1); | |
free(p2); | |
free(p3); | |
return retval; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment