delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/04/23/06:15:20.1

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Cesar Rabak <crabak AT acm DOT org>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Trouble of using very large arrays
Date: Fri, 23 Apr 2004 07:00:45 -0300
Lines: 29
Message-ID: <4088E94D.8070508@acm.org>
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>
NNTP-Posting-Host: 241132.virtua.com.br (200.182.241.132)
Mime-Version: 1.0
X-Trace: news.uni-berlin.de 1082714438 10078972 I 200.182.241.132 ([39218])
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pt-BR; rv:1.0.2) Gecko/20030208 Netscape/7.02
X-Accept-Language: pt-br, pt
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Brian Inglis escreveu:
 > 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;

OK.

 >
 > -- 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.

- Raw text -


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