Advertisement
Guest User

spamram.c

a guest
Jul 15th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3.  
  4. #define Size 4000000
  5.  
  6. typedef struct {
  7. void *parent;
  8. unsigned long *Q;
  9. } orz;
  10.  
  11. void main(void) {
  12. orz *A=NULL, *P=NULL;
  13. unsigned long i = 0, ctr;
  14.  
  15. loopbaby:
  16. A = (orz *) malloc(sizeof(orz));
  17. if (P) A->parent = P;
  18. A->Q = (unsigned long *) malloc(Size*sizeof(unsigned long));
  19. if (A->Q) {
  20. for(unsigned long j=0;j<Size;j++)
  21. A->Q[j] = j;
  22. printf(".");
  23. i++;
  24. P = A;
  25. }
  26. else { free(A); A = P; goto stoploop; }
  27. goto loopbaby;
  28. stoploop:
  29. ctr = i;
  30. printf("Wasted %.2fM RAM!\n",(float)Size*sizeof(unsigned long)*ctr/1024/1024);
  31. printf("\nPress enter."); scanf("%c");
  32. for(; i>0; i--) {
  33. printf("%d ",A->Q[i]);
  34. P = A->parent; free(A->Q); free(A); A = P;
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement