🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.lang.c
Article #15337

Re: Tableau: différence entre pile et tas

#15337
From: dab
Date: Thu, 29 Sep 2005 13:45
19 lines
2098 bytes
Je me trompe peut-être, mais pour moi, les deux allocations qui
suivent sont différentes:
distTable = malloc(NB_MAX_GRID_POINT*sizeof(void *));
for(inc=0; inc<NB_MAX_GRID_POINT; inc++) {
       distTable[inc] =
malloc(NB_NEIGHBOR*sizeof(t_sorted_grid_point));
et
distTable =
malloc(NB_MAX_GRID_POINT*NB_NEIGHBOR*sizeof(t_sorted_grid_point));

La 1ere va allouer NB_MAX_GRID_POINT pointeurs en plus, non?
Et ensuite pour accéder à un élément du tableau, il faudra d'abord
accèder à un pointeur puis à un élement de l'objet pointé.
Est-ce qu'en plus d'économiser de la mémoire, la seconde allocation
diminue le temps d'accès?
Est-ce qu'il y a des inconvénients à allouer des tableaux à N
dimensions de la sorte?

David
Technical Details
Message-ID: <1128001528.130777.214310@z14g2000cwz.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!z14g2000cwz.googlegroups.com!not-for-mail
References: <1127923112.347881.79740@z14g2000cwz.googlegroups.com> <mn.e4827d59f351819c.15512@YOURBRAnoos.fr> <qdx3bnotkkv.fsf@steph.teaser.fr>

Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,9ee84542aed426f5
X-Google-Attributes: gidf9822,public
X-Google-Language: FRENCH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!z14g2000cwz.googlegroups.com!not-for-mail
From: dab@acri-st.fr
Newsgroups: fr.comp.lang.c
Subject: Re: Tableau: différence entre pile et tas
Date: 29 Sep 2005 06:45:28 -0700
Organization: http://groups.google.com
Lines: 20
Message-ID: <1128001528.130777.214310@z14g2000cwz.googlegroups.com>
References: <1127923112.347881.79740@z14g2000cwz.googlegroups.com>
   <mn.e4827d59f351819c.15512@YOURBRAnoos.fr>
   <qdx3bnotkkv.fsf@steph.teaser.fr>
NNTP-Posting-Host: 213.244.27.2
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1128001533 21649 127.0.0.1 (29 Sep 2005 13:45:33 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 29 Sep 2005 13:45:33 +0000 (UTC)
In-Reply-To: <qdx3bnotkkv.fsf@steph.teaser.fr>
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; fr-FR; rv:1.7.10) Gecko/20050717 Firefox/1.0.6,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: z14g2000cwz.googlegroups.com; posting-host=213.244.27.2;
   posting-account=nfO__g0AAAB3e6qRD0Nckfeo-0DvYDH1