home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <malloc.h>
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- char *p;
- int size,i,j;
- if (argc!=2)
- {
- printf("%s: Usage - t number \n",argv[0]);
- printf(" Where 'number' is the number of kilobytes to allocate\n");
- exit(1);
- }
-
- if ((size=atoi(argv[1])) == 0)
- {
- printf("%s: Bad argument, must be integer in kilobytes",argv[0]);
- exit(1);
- }
-
- for (i=0; i<size; i++)
- for (j=0; j<10; j++)
- if ((p=malloc(100))==NULL)
- {
- printf("\nNot enough memory available\n");
- printf("Was only able to allocate %ld bytes",i*1024L+j*100L);
- exit(2);
- } else putchar('.');
- putchar('\n');
- return 0;
- }
-