Guest User

Untitled

a guest
May 23rd, 2014
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define L __LINE__
  5.  
  6. int
  7. main()
  8. {
  9. void *a[3];
  10. int r, i, *ip;
  11.  
  12. printf("%02d, stack:%p\n", L, &r);
  13.  
  14. for (i = 0; i < 3; i++) {
  15. a[i] = malloc(4096);
  16. ip = a[i];
  17. *ip = 123;
  18. printf("%02d, malloc:%02d=%p\n", L, i, a[i]);
  19. }
  20. for (i = 0; i < 3; i++) {
  21. printf("%02d, free:%02d\n", L, i);
  22. free(a[i]);
  23. }
  24.  
  25. for (i = 0; i < 3; i++) {
  26. a[i] = malloc(4096);
  27. ip = a[i];
  28. *ip = 123;
  29. printf("%02d, malloc:%02d=%p\n", L, i, a[i]);
  30. printf("%02d, free:%02d\n", L, i);
  31. free(a[i]);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment