bonjour
j'essaie de faire marcher un truc , en fait je dois allouer dynamiquement un gros tableau qui se trouve dans une structure, mais le truc plante lorsque je libere la memoire
a terme il faut que je passe un pointeur vers la structure a une fonction pour qu'elle traite les donn'es du tableau
voila le principal sous visual :
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>
typedef struct IMAGE {
unsigned char **val; //val[x][y]
} image;
int main()
{
image im;
int x=0,
n=5000;
if ((im.val = (unsigned char**) malloc (sizeof(unsigned char) * n)) == NULL)
printf ("\nechec !\n" );
for (x = 0 ; x < n ; x = x + 1)
{
if ((im.val[x] = (unsigned char*) malloc (n * sizeof(unsigned char))) == NULL)
printf ("ERREUR allocation" );
}
printf ("allocation : x=%i\r", x);
printf ("\n destruction..." );
for (x=0 ; x<n; x=x+1){
printf ("f %i\r", x);
free (im.val[x]);
}
free (im.val);
}
donc voila si quelqu'un a une idée pour faire fonctionner tout ça, mercii !!