home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12284 < prev    next >
Encoding:
Text File  |  1992-08-12  |  1.4 KB  |  93 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!decwrl!netcomsv!netcom.com!feustel
  3. From: feustel@netcom.com (David Feustel)
  4. Subject: Re: Allocating arrays larger than 64K with new?
  5. Message-ID: <f94m37_.feustel@netcom.com>
  6. Date: Wed, 12 Aug 92 23:34:17 GMT
  7. Organization: DAFCO: OS/2 Software Support & Consulting
  8. References: <1992Aug9.152253.11345@newshub.sdsu.edu> <894@nazgul.UUCP>
  9. Lines: 82
  10.  
  11. The following program compiles and links successfully with the ZTC
  12. -mx option. Running the program crashes the system. The program was
  13. linked and run under Flashtek's x32 dos extender.
  14.  
  15. ==============
  16.  
  17. #include <stdio.h>
  18.  
  19. #define AS 3000000
  20.  
  21. long * getspace(unsigned int amount)
  22. {    long * a;
  23.     printf("malloc %d ",amount);
  24.     if(a=(long *) malloc(sizeof(long)*amount))
  25.     {    printf("succeeded\n");
  26.  
  27.     else
  28.  
  29.     {    printf("failed\n");
  30.  
  31.     }
  32.  
  33.     return a;
  34.  
  35. }
  36.  
  37.     
  38.  
  39.  
  40.  
  41. void main(int argc,char **argv)
  42.  
  43. {    long i,imax=AS;
  44.  
  45.     double sum=0;
  46.  
  47.     long *a, *b, *c;
  48.  
  49.     printf("Hello, World\n");
  50.  
  51.     for(i=0;i<argc;++i)
  52.  
  53.     {    printf("%s\n",argv[i]);
  54.  
  55.     }
  56.  
  57.     a=getspace(AS);
  58.  
  59.     b=getspace(AS);
  60.  
  61.     c=getspace(AS);
  62.  
  63.     if (a==0|b==0|c==0) exit(-1);
  64.  
  65.     for(i=0;i<imax;++i)
  66.  
  67.     {    
  68.  
  69.         a[i]=i*i;
  70.  
  71.         b[i]=i;
  72.  
  73.         c[i]=i*i*i;
  74.  
  75.         sum+=a[i]+b[i]+c[i];
  76.  
  77.     }
  78.  
  79.     free(a); free(b); free(c);
  80.  
  81.     printf("sum: %e\n",sum);
  82.  
  83.     exit(0);
  84.  
  85. }
  86.  
  87.  
  88. -- 
  89. Dave Feustel N9MYI <feustel@netcom.com>
  90. ---
  91. Given Civil Seizure, from the DEA's point of view, winning the War on
  92. Drugs would be killing the Goose that lays golden eggs.
  93.