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 agoYou've missed out part of the code. Presumably the full code is:
unsigned char * data_written;
data_written = (unsigned char *)malloc(0x1000);
num=sizeof(data_written); So data_written is a pointer, and pointers are 32 bits on Nios II - four times the size of a char. So sizeof is returning the correct value.