lliyanc
BAN USERwhen using malloc, it returns void type. we need to type cast. And the acutall memory allocated is larger than you applied, the first part stores the number of bytes allocated (offset to teh next memory from the start of this memroy). For example, if you do int *i = (int*) malloc(12), it allocates 16 bytes. The first 4 bytes for actuall size, from 5th byte is return to i, now i can acess 12 bytes from this byte.
- lliyanc March 26, 2012when using malloc, it returns void type. we need to type cast. And the acutall memory allocated is larger than you applied, the first part stores the number of bytes allocated (offset to teh next memory from the start of this memroy). For example, if you do int *i = (int*) malloc(12), it allocates 16 bytes. The first 4 bytes for actuall size, from 5th byte is return to i, now i can acess 12 bytes from this byte.
- lliyanc March 26, 2012
- lliyanc January 21, 2016