1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
typedef struct
{
char Id[20];
char Affiche[60];
} StructureListe;
void Rempli (StructureListe **Liste, unsigned int *count)
{
StructureListe ListeTmp;
....
*count = 3;
ListeTmp = malloc ( sizeof(StructureListe) * count); // 1 allocation mémoire sur pointeur local
......
*Liste = ListeTmp; // 2 affectation valeur au paramètre
}
void main (void)
{
StructureListe *ListeMain;
unsigned int CountMain;
Rempli(&ListeMain, &CountMain);
....
free (ListeMain); // 3 libération mémoire
} |