X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: Trouble of using very large arrays Date: 23 Apr 2004 10:08:36 GMT Lines: 20 Message-ID: References: <4088E94D DOT 8070508 AT acm DOT org> NNTP-Posting-Host: accip02.physik.rwth-aachen.de (137.226.33.41) X-Trace: news.uni-berlin.de 1082714916 10486432 D 137.226.33.41 ([231750] 10357) X-Orig-Path: not-for-mail To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Cesar Rabak wrote: > Brian Inglis escreveu: [...] > > -- avoid using types for sizes, in case someone later changes the > > assigned pointer type; use object sizes instead; > > > > this is cleaner and more maintainable: > > > > a = malloc(rows * columns * sizeof *a); > > > This is not a good advice: you're changing the allocation of an object > of (rows x columns) ints to another of (rows x columns) pointers to int. No, he's not. The type of *a is int, not pointer to int. See Alex's original code --- he silently changed the OP's two-dimensional array to a one-dimensional one with manually computed indexing. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.