delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/04/23/04:16:44

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Trace-PostClient-IP: 68.147.131.211
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT Invalid>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Trouble of using very large arrays
Organization: Systematic Software
Message-ID: <urih80l3b6om4kbblr8jthpjbm1i7cp6gc@4ax.com>
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>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Lines: 24
Date: Fri, 23 Apr 2004 08:07:15 GMT
NNTP-Posting-Host: 24.71.223.147
X-Complaints-To: abuse AT shaw DOT ca
X-Trace: pd7tw1no 1082707635 24.71.223.147 (Fri, 23 Apr 2004 02:07:15 MDT)
NNTP-Posting-Date: Fri, 23 Apr 2004 02:07:15 MDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Thu, 22 Apr 2004 20:10:08 +0300 in comp.os.msdos.djgpp, "Alex
Vinokur" <alexvn AT big DOT foot DOT com> wrote:

>  a = (unsigned int*)malloc (rows * columns * sizeof (unsigned int));

Nitpicks: 

-- avoid casting malloc results, as it is unnecessary to cast a void
pointer to any other type of pointer, but the explicit cast will mask
not declaring malloc or including stdlib.h, and also mask assignment
to a non-pointer type; 

-- 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);

-- 
Thanks. Take care, Brian Inglis 	Calgary, Alberta, Canada

Brian DOT Inglis AT CSi DOT com 	(Brian dot Inglis at SystematicSw dot ab dot ca)
    fake address		use address above to reply

- Raw text -


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