0
我在Xcode中奇怪的malloc坏访问
分配使用malloc内存出现问题。当我使用一个较小的BLOCK_SIZE(256)的代码有没有问题 如果我用更大的BLOCK_SIZE(65536)Xcode的将停止在“state1 [t] =(int *)malloc(sizeof(int)* 4);”并告诉我BAD_ACCESS。如何解决这个问题呢?
由于
int main(int argc, const char * argv[]) {
// insert code here...
int **state1;
int t = 0;
int Block_size = 65535;
state1 = (int **)malloc(sizeof(int) * Block_size);
printf("%d",Block_size);
for (t=0 ; t < Block_size-1 ; t++) {
state1[t] = (int*) malloc(sizeof(int) * 4);
}
printf("end");
return 0;
}