动态申请二维数组空间
short **Alloc_Short_Img (char x_size,char y_size){
char m;
short **map ;
short *array;
map = (short **)malloc(sizeof(short) * x_size * y_size);
for(m=0;m<y_size;m++)
{
array = (short *)malloc(sizeof(short) * x_size);
map[m] = array ;
}
return map;
}
short **Alloc_Short_Img (char x_size,char y_size)
{
char m;
short **map,*array;
map = (short **)malloc(sizeof(short*) * y_size);
array = (short *)malloc(sizeof(short) * x_size * y_size);
for(m=0;m<y_size;m++)
{
map[m] = &array[m*x_size] ;
}
return map;
}
上面的两种方法,哪一种比较好呢 ??