www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/13/13:50:58

Date: Wed, 13 Oct 1999 13:15:34 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Nicolas Blais <nicblais AT hotmail DOT com>, djgpp AT delorie DOT com
Subject: Re: Please help...matrix problem with Allegro
In-Reply-To: <Pine.SUN.3.91.991010122036.19618N-100000@is>
Message-ID: <Pine.SUN.3.91.991013131434.17265B-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sat, 9 Oct 1999, Nicolas Blais wrote:

> ushort pix_x;
> ushort pix_y;
> ushort color_red;
> unsigned int matrix[res_x][res_y] = {{0}};

I probably should have seen this sooner, but the incomplete source
didn't help: you are declaring a large automatic array, and it
overflows the run-time stack.  matrix[res_x][res_y] is declared int,
so each element takes 4 bytes.  640*480*4 is *way* more than 512K
bytes, the size of the run-time stack allocated by the startup code.

Section 15.9 of the FAQ describes the two ways you can use to enlarge
the stack.  But I suggest to make your matrix either a static array 
(outside of any function) or to allocate it at run time by a call to 
malloc.

- Raw text -


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