下面这么free有无问题
现在有一个结构体
typedef struct result_tag
{
int num;
unsigned char* img;
unsigned char** accu_img; //保存多帧图像
}result_t, *presult_t;
int width, height, accu_cnt, i;
width = 704;
height = 576;
accu_cnt = 50;
result_t *result = ( result_t* )malloc( sizeof( result ) );
result->img = ( unsigned char* )malloc( width * height * sizeof( unsigned char ) );
result->accu_img = ( unsigned char** )malloc( accu_cnt * sizeof( unsigned char* ) );
for( i = 0; i < accu_cnt; i++ )
{
result->accu_img[i] = ( unsigned char* )malloc( width * height * sizeof( unsigned char ) );
}
free(result); //这里有没有问题?还是需要先把申请的result->img和result->accu_img释放掉
//再释放result?
resultresult = NULL;
malloc(1);
malloc(2);
malloc(3);
free(3);
free(2);
free(1);