🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Re: Tableau: différence entre pile et tas

#15366
From: Emmanuel Delahaye
Date: Fri, 30 Sep 2005 14:16
47 lines
2536 bytes
dab@acri-st.fr wrote on 29/09/05 :
>> Pourquoi (void *) ?
>
> Dans la mesure ou je veux allouer un tableau de pointeur,
> est-ce que �a change quelque chose d'utiliser (void*) ou
> (t_grid_point*) dans mon malloc?

D'essayer d'�tre coh�rent... Sans parler des risques de non 
portabilit�...

> t_grid_point* gridPointTable = malloc
> (NB_MAX_GRID_POINT*sizeof*gridPointTable);
> L� par contre, je veux bien une explication STP :)
> Pourquoi tu utilises le nom de la variable dans le malloc:
> gridPointTable?

C'est la mise en oeuvre du principe g�n�ral :

T* p = malloc (n *sizeof *p);

evidemment, �a ne fonctionne pas avec T �tant void, d'o� ma remarque.

> Qu'est-ce que �a a comme sens et comme effet?

p �tant typ� (T), *p repr�sente un objet de type T. Sa taille est donc 
de sizeof *p bytes.

L'interet est que le codage est simplifi�.

- Diminution du risque d'erreur
- R�duction de la maintenance.

http://mapage.noos.fr/emdel/notes.htm#malloc

> Et vu que tu fait la m�me chose pour les 2 autres malloc,
> je suppose que ce n'est pas un hasard ou une erreur.

Evidemment non!

-- 
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

"Clearly your code does not meet the original spec."
"You are sentenced to 30 lashes with a wet noodle."
-- Jerry Coffin in a.l.c.c++
Technical Details
Message-ID: <mn.f3d07d595273bf72.15512@YOURBRAnoos.fr>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!transit.nntp.hccnet.nl!transit1.nntp.hccnet.nl!feeder3.cambrium.nl!feed.tweaknews.nl!proxad.net!infeed-4.proxad.net!news18-e.free.fr!not-for-mail
References: <1127923112.347881.79740@z14g2000cwz.googlegroups.com> <mn.e4827d59f351819c.15512@YOURBRAnoos.fr> <1127977421.754045.184600@g49g2000cwa.googlegroups.com>

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!news4.google.com!news.glorb.com!transit.nntp.hccnet.nl!transit1.nntp.hccnet.nl!feeder3.cambrium.nl!feed.tweaknews.nl!proxad.net!infeed-4.proxad.net!news18-e.free.fr!not-for-mail
Subject: Re: Re: Tableau: différence entre pile et tas
From: "Emmanuel Delahaye" <emdel@YOURBRAnoos.fr>
References: <1127923112.347881.79740@z14g2000cwz.googlegroups.com> <mn.e4827d59f351819c.15512@YOURBRAnoos.fr> <1127977421.754045.184600@g49g2000cwa.googlegroups.com>
Newsgroups: fr.comp.lang.c
Message-ID: <mn.f3d07d595273bf72.15512@YOURBRAnoos.fr>
X-Newsreader: MesNews/1.04.00.00-fr
Date: Fri, 30 Sep 2005 16:16:49 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 49
Organization: Guest of ProXad - France
NNTP-Posting-Date: 30 Sep 2005 16:16:49 MEST
NNTP-Posting-Host: 81.65.109.78
X-Trace: 1128089809 news18-e.free.fr 4331 81.65.109.78:13471
X-Complaints-To: abuse@proxad.net