Guest User

Untitled

a guest
Oct 22nd, 2019
161
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void f()
  2. {
  3. int *a = malloc(ASIZE);
  4. if(!a) goto END;
  5.  
  6. int *b = malloc(BSIZE);
  7. if(!b) goto FREE_A;
  8.  
  9. int **c = malloc(CSIZE);
  10. if(!c) goto FREE_B;
  11.  
  12. int i;
  13. for(i=0; i<CSIZE; i++) {
  14. c[i] = malloc(N);
  15. if(!c[i]) goto FREE_C;
  16. }
  17.  
  18. /* Do stuff */
  19.  
  20. FREE_C:
  21. while(i>=0)
  22. free(c[i--]);
  23.  
  24. free(c);
  25. FREE_B:
  26. free(b);
  27. FREE_A:
  28. free(a);
  29. END:
  30. }
  31.  
  32. void f()
  33. {
  34. for(int i=0; i<A; i++) {
  35. for(int j=0; j<B; j++) {
  36. for(int k; k<B; k++) {
  37. if(condition)
  38. goto END;
  39. /* Do stuff */
  40. }
  41. }
  42. }
  43. END:
  44. }
RAW Paste Data