Malloc sur un pointeur élément d'une structure
Hello,
Soit la structure suivante :
Code:
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 27 28 29
|
typedef struc maStructure
{
float* array;
} maStructure;
maStructure*data = NULL;
void uneFonction()
{
data = (maStructure*)malloc(sizeof(maStructure));
data->array = (float*)malloc(10*sizeof(float));
}
void uneAutreFonction()
{
if (data)
{
if (data->inputs)
free(data->inputs);
free(data);
}
}
void main()
{
uneFonction();
uneAutreFonction();
} |
L'instruction fait planter mon programme. Pourquoi ?
J'ai évidemment fait des simplifications de code...
Merci pour vote aide.