分类:
2009-04-02 10:07:49
| |||
Regarding malloc memory alignment
Hi Group, I have one question. If I am allocating memory of 38 bytes to an integer pointer, what will be the memory actually allocated? Will there be any memory alignment concept in malloc? Please let me know the reasons if it is yes / no. Regards Ram. |
#
| |||
| |||
Re: Regarding malloc memory alignment writes: Quote:
Quote:
and possibly more (or no bytes of memory, if the request cannot be satisfied). How much more depends on your implementation and possibly on the preexisting state of the system. Quote:
C purpose. The C standard says this explicitly: The pointer returned if the allocation succeeds is suitably aligned so that it may be assigned to a pointer to any type of object and then used to access such an object or an array of such objects in the space allocated (until the space is explicitly deallocated). -- "If I've told you once, I've told you LLONG_MAX times not to exaggerate." --Jack Klein |