Date: Thu, 28 Oct 1999 19:14:57 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Nicolas Blais cc: djgpp AT delorie DOT com Subject: Re: Stack space In-Reply-To: <7v71od$vas$1@nnrp1.deja.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Wed, 27 Oct 1999, Nicolas Blais wrote: > All of my DJGPP progs use the default stack space of 512K. So, > obviously my programs crashes when it uses more then 512K. I know I can > change this value with stub but I don't really want to. What I want to > do is to create a variable with new like such: > double x = new double; > > And make him use a part of memory that's already in use by another > program, like windows for example. Let's say that I have that address > and I want to store a new variable there, how could I do it? You are mixing several types of ``memory'' used by the DJGPP programs in particular and by other programs running on Windows, in general. First, besides the stack, your program also uses the ``heap'', a portion of memory that is allocated by calls to malloc and new. The stack is only used by variables that are local to functions, like in the following example: int foo (void) { int i, j, array[20]; ... return 0; } In this function, the variables i, j, and array[] are allocated space on the stack. Because of the heap, your program can use more than 512KB and not crash, provided that you use new to allocate memory. As to using memory that is already in use by other programs, it's impossible: Windows runs each program in its own ``virtual machine'' whose address space is totally separated from that of other programs. You cannot reference the same memory from two different DJGPP programs, not on Windows.