Forum Discussion
Altera_Forum
Honored Contributor
21 years agomalloc( )problem
Hello : data_written = (unsigned char *)malloc(0x1000); num=sizeof(data_written); The size of data_written should be 0x1000,But use the function sizeof,the num is 4 . I hav...
Altera_Forum
Honored Contributor
21 years agoTo
the below code is in the memtest.c data_written = (void*)alt_uncached_malloc(0x1000); data_read = (void*)alt_uncached_malloc(0x1000); /* Fill write buffer with known values */ for (pattern = 1, offset = 0; offset < sizeof(data_written); pattern++, offset+=4) { IOWR_32DIRECT((int)data_written, offset, pattern); } /* Fill write buffer with known values */ Fill the write buffer But if the sizeof(data_written) is only 4 ,the for sentence do what? and after malloc( ) the content in the location of memory is random number?