Fwd: Re: Is there heap size limitaion?

Anna Sidera eep6sa1@ucy.ac.cy
Thu Jan 8 03:13:00 GMT 2009


Thank you for your help. I used sizeof(int *) and it worked.

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
int main()
{

int i, j;

int **table1=malloc(10000000*sizeof(int*));
int *table1_aux=(int *)malloc(10000000*100*sizeof(int));
for (i=0; i<10000000; i++) table1[i]=table1_aux+i*100;
for (i=0; i<10000000; i++) {
for (j=0; j<100; j++) {
         table1[i][j]=0;
}
}
printf("table1 ok\n");

int **table2=malloc(10000000*sizeof(int*));
int *table2_aux=(int *)malloc(10000000*100*sizeof(int));
for (i=0; i<10000000; i++) table2[i]=table2_aux+i*100;
for (i=0; i<10000000; i++) {
for (j=0; j<100; j++) {
         table2[i][j]=0;
}
}
printf("table2 ok\n");

return 0;
}

-------------- next part --------------
An embedded message was scrubbed...
From: Andrew Haley <aph@redhat.com>
Subject: Re: Is there heap size limitaion?
Date: Mon, 05 Jan 2009 14:33:16 +0000
Size: 3658
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20090108/ae82763e/attachment.eml>


More information about the Gcc-help mailing list