Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int useGoto()
- {
- if(fun1())
- goto errorCleanup;
- doit();
- if(fun2())
- goto errorCleanup;
- doit();
- if(fun3())
- goto errorCleanup;
- doit();
- return 0;
- errorCleanup:
- cleanup1();
- cleanup2();
- cleanup3();
- return 1;
- }
- int nestedIf()
- {
- if(fun1() == 0)
- {
- doit();
- if(fun2() == 0)
- {
- doit();
- if(fun3() == 0)
- {
- doit();
- }
- else
- {
- cleanup1();
- cleanup2();
- cleanup3();
- return 1;
- }
- }
- else
- {
- cleanup1();
- cleanup2();
- cleanup3();
- return 1;
- }
- }
- else
- {
- cleanup1();
- cleanup2();
- cleanup3();
- return 1;
- }
- return 0;
- }
- int singleIfBoolean()
- {
- if(fun1() && (doit(), 1) && fun2() && (doit(), 1) && fun3() && (doit(), 1))
- {
- return 0;
- }
- else
- {
- cleanup1();
- cleanup2();
- cleanup3();
- return 1;
- }
- }
- int nonNestedIfButRepeatedCode()
- {
- if(fun1() != 0)
- {
- cleanup1();
- cleanup2();
- cleanup3();
- return 1;
- }
- doit();
- if(fun2() != 0)
- {
- cleanup1();
- cleanup2();
- cleanup3();
- return 1;
- }
- doit();
- if(fun3() != 0)
- {
- cleanup1();
- cleanup2();
- cleanup3();
- return 1;
- }
- doit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement