Article View: fr.comp.lang.c
Article #15418Tableau: différence entre pile et tas
From: dab
Date: Wed, 28 Sep 2005 15:58
Date: Wed, 28 Sep 2005 15:58
36 lines
2193 bytes
2193 bytes
Bonjour à tous
J'ai un bout de code qui utilise des tables:
#define NB_MAX_GRID_POINT 2621442
#define NB_NEIGHBOR 6
t_grid_point* gridPointTable[NB_MAX_GRID_POINT];
t_sorted_grid_point distTable[NB_MAX_GRID_POINT][NB_NEIGHBOR];
Pour commencer à developper, j'avais une valeur de 50 pour
NB_MAX_GRID_POINT,
mais maintenant que j'utilise la véritable valeur de
NB_MAX_GRID_POINT,
je me prend un segmentation fault à l'execution.
Du coup, je me dis que c'est la taille de mon tableau en pile qui pose
soucis,
je vais donc allouer mon tableau dans le tas.
et hop:
gridPointTable = malloc(NB_MAX_GRID_POINT*sizeof(void *));
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));
}
Est-ce que je suis censé utiliser mes tableaux différements
maintenant?
Qu'est-ce que je dois prendre comme précaution supplémentaire?
Merci d'avance
David
PS: Je n'ai rien trouver dans le bouquin de K&R à ce sujet.
Technical Details
Message-ID:
<1127923112.347881.79740@z14g2000cwz.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!z14g2000cwz.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: f9822,9ee84542aed426f5,start 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: Tableau: différence entre pile et tas Date: 28 Sep 2005 08:58:32 -0700 Organization: http://groups.google.com Lines: 37 Message-ID: <1127923112.347881.79740@z14g2000cwz.googlegroups.com> 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 1127923117 18858 127.0.0.1 (28 Sep 2005 15:58:37 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 28 Sep 2005 15:58:37 +0000 (UTC) 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