| delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
| From: | "Alex Vinokur" <alexvn AT foot DOT com> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: Trouble of using very large arrays |
| Date: | Fri, 23 Apr 2004 20:48:04 +0300 |
| Lines: | 43 |
| Message-ID: | <c6bksm$a2b90$1@ID-79865.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> <40894F42 DOT B60859A7 AT yahoo DOT com> |
| NNTP-Posting-Host: | 82.166.217.24 |
| X-Trace: | news.uni-berlin.de 1082742487 10562848 I 82.166.217.24 ([79865]) |
| X-Priority: | 3 |
| X-MSMail-Priority: | Normal |
| X-Newsreader: | Microsoft Outlook Express 6.00.2800.1106 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.2800.1106 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
"CBFalconer" <cbfalconer AT yahoo DOT com> wrote in message news:40894F42 DOT B60859A7 AT yahoo DOT com...
> Alex Vinokur wrote:
> > "Martin Ambuhl" <mambuhl AT earthlink DOT net> wrote in message
> >> 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.
> >
------ My mistake ------
> > You are right. So,
> > a = malloc(rows * columns * sizeof a);
------------------------
> ^^
> No no, 1000 times no, that should be "*a".
>
Of course,
char* a1 = malloc(rows * columns * sizeof *a1); /* malloc(rows * columns * sizeof (char)); */
int* a2 = malloc(rows * columns * sizeof *a2); /* malloc(rows * columns * sizeof (int)); */
long* a3 = malloc(rows * columns * sizeof *a3); /* malloc(rows * columns * sizeof (long)); */
[snip]
--
Alex Vinokur
mailto:alexvn AT connect DOT to
http://mathforum.org/library/view/10978.html
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |