delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
From: | Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de> |
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: | <c6apv4$a00l0$1@ID-231750.news.uni-berlin.de> |
References: | <c68d6j$g57$03$1 AT news DOT t-online DOT com> <c68e70$96gqq$1 AT ID-231750 DOT news DOT uni-berlin DOT de> <c68u9l$9fevb$1 AT ID-79865 DOT news DOT uni-berlin DOT de> <urih80l3b6om4kbblr8jthpjbm1i7cp6gc AT 4ax DOT com> <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 <crabak AT acm DOT org> 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.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |