delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/12/13/11:30:06

From: "Louis P. Santillan" <lsantil AT calstatela DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: 40 MB buffer
Date: Fri, 13 Dec 2002 08:26:14 -0800
Organization: CSUnet
Lines: 57
Message-ID: <Pine.GSO.4.21.0212130820060.17931-100000@neptune.calstatela.edu>
References: <F135Nbo9BYoqhF9cQoN0001a3e5 AT hotmail DOT com>
NNTP-Posting-Host: neptune.calstatela.edu
Mime-Version: 1.0
In-Reply-To: <F135Nbo9BYoqhF9cQoN0001a3e5@hotmail.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

In what context is this code running?  If the data declaration is outside
of a function (global space), then it should be allocated correctly but
you'll also end up with a 40MB+ EXE file.  If you have this code contained
in a function (local space; say main function), then you're trying to
allocate 40MB of stack space which I'm sure almost any compiler wont let
you do (easily at least).  You may wanna try this instead.

#include <stdio.h>
#include <stdlib.h>

int main( int argc, char **argv )
{
   int *buf = ( int* )( malloc( 10000000 * sizeof( int ) ) );
   int i;

   /* code to print contents of buf */

   free( buf );

   return( 0 );
}



Louis

On Fri, 13 Dec 2002, wes kotala wrote:

> I just download the DJGPP software and I love it.
> 
> Here is my question. I need be able to store 40 MB of data in memory. How do 
> I do this? I was hoping I could just declare a 40 MB buffer but this is 
> giving me errors when I run it.
> 
> Here is part of my code that I wrote to test. I am assuming it isn't as 
> simple to do as I had hoped. Any help in this area would be GREATLY 
> APPRECIATED.
> 
> Thank you in advance.
> Wes
> 
> 
> int i;
> int buffer[10000000];
> 
> for(i=0;i<10000000;i++)
>    buffer[i]=0;
> for(i=0;i<10000000;i++)
>    printf("%d\n",buffer[i])
> 
> _________________________________________________________________
> Tired of spam? Get advanced junk mail protection with MSN 8. 
> http://join.msn.com/?page=features/junkmail
> 
> 


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019