fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct _Foo_
  5. {
  6. int number;
  7. char character;
  8. float ratio;
  9.  
  10. } Foo;
  11.  
  12. Foo* createFoo()
  13. {
  14. return (Foo*)malloc(sizeof(Foo));
  15. }
  16.  
  17. void destroyFoo(Foo** foo)
  18. {
  19. if (!foo | !(*foo)) return;
  20. free(*foo);
  21. *foo = NULL;
  22. }
  23.  
  24. int main()
  25. {
  26. Foo* a = NULL;
  27. Foo* b = createFoo();
  28.  
  29. destroyFoo(NULL);
  30. destroyFoo(&a);
  31. destroyFoo(&b);
  32.  
  33. printf("success");
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0s 2244KB
stdin
Standard input is empty
stdout
success