Free et Segmentation fault
Bonsoir,
Voici une partie de mon code qui me pose problème. Dans certains cas, une erreur de segmentation se produit au niveau de "free (mat[i])". Comment est-ce possible ?
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
| typedef struct test {
int **mat;
int x;
int y;
int c;
struct test *prec;
} test_t;
static void mat_free (int ** mat)
{
for (int i = 0; i < TAILLE; i++)
free (mat[i]);
free (mat);
}
static void pile_free(test_t *pile)
{
while (pile->prec != NULL)
{
pile = pile->prec;
pile_free(pile);
mat_free(pile->mat);
free(pile);
}
} |
Merci d'avance.