fork download
  1. #include <stdlib.h>
  2. struct l {
  3. struct l *next;
  4. int data;
  5. } *root = 0;
  6.  
  7. void free_l(struct l *p) {
  8. if (p->next)
  9. free_l(p->next);
  10. free(p);
  11. }
  12.  
  13. #define N 10000000
  14. int main(int argc, char **argv) {
  15. unsigned long i;
  16. for (i = 0; i < N; i++) {
  17. struct l *p = malloc(sizeof(struct l));
  18. p->next = root;
  19. root = p;
  20. }
  21. if (argc == 2) {
  22. struct l *p = root, *q;
  23. while (p) {
  24. q = p->next;
  25. free(p);
  26. p = q;
  27. }
  28. } else if (argc ==1) {
  29. free_l(root);
  30. }
  31. return 0;
  32. }
  33. /* end */
  34.  
Runtime error #stdin #stdout 0.81s 166080KB
stdin
Standard input is empty
stdout
Standard output is empty