delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/06/06:46:07

Message-ID: <E1FF8239A075D311AF7200A0C9D60AE30A64FB@probe-2.acclaim-euro.net>
From: Shawn Hargreaves <SHargreaves AT acclaimstudios DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: Please help...matrix problem with Allegro
Date: Wed, 6 Oct 1999 10:20:11 +0100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.0)
Reply-To: djgpp AT delorie DOT com

nicblais AT my-deja DOT com writes:
> unsigned int matrix[res_x][res_y];

Depending on how big res_x and res_y are, this might be
overflowing your stack: there is only limited space for
local variables, so it would be better to use dynamic
allocation (ie. malloc) for any big arrays.

>      pix_x = (random() % res_x) + 1;

This is a potential array overflow: C arrays count from
zero, so you don't want that + 1 on the end.

Also, you didn't initialise your array to anything, so
the starting contents are random. You need to fill it
with zeros before you can sensibly check for whether
values are set or not.


	Shawn Hargreaves.

- Raw text -


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