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

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Trouble of using very large arrays
Date: Fri, 23 Apr 2004 20:08:38 -0400
Lines: 32
Message-ID: <c6cb68$aht8h$4@ID-227552.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> <c6bafb$a9mhn$2 AT ID-227552 DOT news DOT uni-berlin DOT de> <c6bf2n$a164m$1 AT ID-79865 DOT news DOT uni-berlin DOT de>
NNTP-Posting-Host: user-2ive6t3.dialup.mindspring.com (165.247.27.163)
Mime-Version: 1.0
X-Trace: news.uni-berlin.de 1082765320 11072785 I 165.247.27.163 ([227552])
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113
X-Accept-Language: en-us, en, de, fr, ru, zh, ja
In-Reply-To: <c6bf2n$a164m$1@ID-79865.news.uni-berlin.de>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Alex Vinokur wrote:

> "Martin Ambuhl" <mambuhl AT earthlink DOT net> wrote in message news:c6bafb$a9mhn$2 AT ID-227552 DOT news DOT uni-berlin DOT de...
> 
>>Cesar Rabak wrote:
>>
>>
>>>Brian Inglis escreveu:
>>
>>> > 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.
>>
>>You are, I regret to say, in error.  The type of *a is int, not
>>pointers-to-int.
>>
> 
> 
> You are right. So,
>  a = malloc(rows * columns * sizeof  a);

Huh?  Why change the correct
    a = malloc(rows * columns * sizeof *a);
to something that's wrong?

The fact is that
   ptr = malloc(number * sizeof *ptr);
is the accepted, common C idiom here, no matter what the type of ptr. 
That's the point.

- Raw text -


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