Last active
February 10, 2023 09:19
-
-
Save PttCodingMan/21cfbae514cab93d41ee1980a9de6de6 to your computer and use it in GitHub Desktop.
C language function example to avoid memory leak using goto.
This file contains hidden or 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 func(....){ | |
// declare variable here | |
// check input here | |
if(pointer == NULL) goto end; | |
if(!run_condition) goto end; | |
// do something | |
if(!run_condition) goto end; | |
end: | |
// free pointers here | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment