Bonjour à tous,
quand je compile mon programme ya une bizarre erreur qui s'affiche glibc detected double free or corruption]
je pense que c'est à cause de la fonction suivante :
car quand je la met en commentaire, tout se passe nikel:?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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 int nbrLignesCommunes(ChainonMot const * pc,ChainonMot const * pc2) { /* Permettra de parcourir les deux liste (FR et AN) */ ChainonCoord const *pcCoord; ChainonCoord const *pcCoord2; /* Permet de verifier si le numero de la ligne n'est pas deja compter dans la solution */ int k; /* Tableau dynamique */ int *LigneCommune = (int*) malloc (sizeof(int)); int nombreDeSolution = 0; for(pcCoord = coord_GetPremierC(GetPtrCoordC(pc)) ; pcCoord!=NULL ; pcCoord=coord_GetNextC(pcCoord)) { for(pcCoord2 = coord_GetPremierC(GetPtrCoordC(pc2)) ; pcCoord2!=NULL ; pcCoord2=coord_GetNextC(pcCoord2)) { if (GetLigne(pcCoord) == GetLigne(pcCoord2)) { /* Se comportera comme un booleen */ int nouvelleLigne = 1; if(LigneCommune == NULL) { printf("!!!!"); exit(1); } // // /* On va chercher a savoir si la ligne est deja presente */ for (k=0 ; k<nombreDeSolution ; k++) if (LigneCommune[k] == GetLigne(pcCoord)) nouvelleLigne = 1; // if (nouvelleLigne) { LigneCommune[nombreDeSolution] = GetLigne(pcCoord); nombreDeSolution++; int *Temporaire = realloc(LigneCommune, sizeof(int)*(nombreDeSolution + 1)); if (Temporaire != NULL) { free(LigneCommune); LigneCommune = Temporaire; } else { printf ("Probleme lors du realloc !"); exit(1); } } } } } return nombreDeSolution; }
Une idée?
merci