Changement de contenu après un realloc
Salut,
je fais un realloc sur un tableau d'unsigned long..
Et il semble que le contenu de ce tableau change avant/après le réalloc..
De plus, le pointeur semble changer lorsqu'il s'agit de gros tableaux (alors que mes réallocs sont forcement d'une taille inférieure.. mais c'est peut etre normal, y a t il recopie si la taille est plus petite ?)
Code :
Code:
1 2 3 4 5 6 7 8 9 10 11
|
for(i=0 ; i<orientedGraph->nbArcs*2 ; ++i) printf("%ld ", notOriented->allAdjOut[i]);
printf("\n");
if((notOriented->allAdjOut = realloc(notOriented->allAdjOut, notOriented->nbArcs*2)) == NULL) {
perror("realloc");
return NULL;
}
for(i=0 ; i<notOriented->nbArcs ; ++i) printf("%ld ", notOriented->allAdjOut[i]);
printf("\n"); |
Et cela donne :
Citation:
1 2 0 0 3 4 2 2 6 5 0 0
1 2 0 41 1628733340 1628733340 2 2 6 5