| delorie.com/archives/browse.cgi | search |
| Date: | Mon, 9 Nov 92 10:35:10 -0500 |
| From: | Ken Lin <kylin AT onnes DOT physics DOT sunysb DOT edu> |
| Subject: | malloc |
| Apparently-To: | djgpp AT sun DOT soe DOT clarkson DOT edu |
Try this program:
#include <stdio.h>
#include <stdlib.h>
void main(void)
{
char *s;
int i=0,j=0;
while (s=(int *)malloc(sizeof(int)*1024))
{
i=i+sizeof(int);
++j;
printf("%d %d \n",j,i);
}
}
Execution on my 386 results in an exception error after allocation of
about 10MB. Since I only have 4MB RAM, the other 6MB must be from
disk. But there is no graceful exit....
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |