www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/02/09/12:27:21

Date: Sun, 9 Feb 2003 12:26:59 -0500
Message-Id: <200302091726.h19HQxp16523@envy.delorie.com>
X-Authentication-Warning: envy.delorie.com: dj set sender to dj AT delorie DOT com using -f
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <b25thp$g512@imsp212.netvigator.com> (luckie@netvigator.com)
Subject: Re: allocating big chunks with djgpp
References: <b25thp$g512 AT imsp212 DOT netvigator DOT com>
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

> with 16-bit DOS compilers, char buffer[30000][81] seems unrealistic and
> infeasible. Now with Djgpp, how do I allocate such a big buffer in terms of
> what syntax is used? or leave that code snippet intact and the linker will
> function okay?

Yeah, that syntax "just works" with djgpp.  Note, however, that there
is still a limit to stack space, so if you try to create a buffer like
that as a local variable (i.e. inside a function) you'll have
problems.  If you need a local-scope variable, at least make it
static, or use malloc/free.


ok:
	char buffer[30000][81];

	int foo()
	{
	  static char buffer[30000][81];
	  char **buffer2 = malloc(30000 * 81);
	}

bad:
	int foo()
	{
	  char buffer[30000][81];
	}

If needed, however, you can use djgpp's stubedit to increase the size
of the stack to 3mb or more for that particular buffer.

- Raw text -


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