使用malloc分配内存较快,且能得到分配的内存地址
int i = 0;
alt_u32 len3d = 10;//512*1024;
alt_u32 sum1 = 0, sum2 = 0;
UC *ram = (UC *)malloc ( sizeof(UC)* len3d );
if (ram==NULL) {
printf("ram == null");
}else{
printf("addr = %x \n", ram);
}
UC tmpData;
for(i=0;i<len3d;i++){
tmpData = (UC)(rand()&0xFF);
*(ram + i) = tmpData;
sum1 = sum1 + tmpData;
printf("data1 = %d\n", *(ram + i));
}
for(i=0;i<len3d;i++){
sum2 = sum2 + (*(ram + i));
printf("data2 = %d\n", *(ram + i));
}
printf("sum1 = %d\n, sum2 = %d\n", sum1, sum2);
free (ram);