malloc and padding
Posted on 2013-11-22
I have a question - If the memory I am reading back seems to be padded to make it aligned to byte boundaries, who is responsible to make sure that sufficient memory was allocated when the writing took place initially.
For example,, i wrote a series of structs. When i read back i allocated number_of_struct*sizeof(struct mystruct) using malloc. However on looking through the memory returned to me, i find it padded. Was i supposed to allocate number_of_struct*(sizeof(struct mystruct)+padding) using malloc or is the extra memory allocation handled by the compiler?