malloc.c 731 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. ** Written by David Gerdes US Army Construction Engineering Research Lab
  3. ** April 1992
  4. ** Copyright 1992 USA-CERL All rights reserved.
  5. **
  6. */
  7. /*
  8. ** takes 1st command line argument and stuffs each letter of it into
  9. ** a linked list. then prints it back out to stdout.
  10. ** If a second argument is specified, the first argument is put in the
  11. ** list backwards.
  12. */
  13. #include <stdio.h>
  14. #include <grass/linkm.h>
  15. struct link
  16. {
  17. char let;
  18. struct link *next;
  19. };
  20. int main(int argc, char *argv[])
  21. {
  22. register int i;
  23. VOID_T *head;
  24. struct link List, *tmp, *p;
  25. int rev = 0;
  26. for (i = 0; i < 2000000; i++) {
  27. p = (struct link *)malloc(sizeof(struct link));
  28. free(p);
  29. }
  30. exit(0);
  31. }