Ordinary dynamic memory allocation guarantees that the allocated memory is properly aligned for any scalar object of a native type (for instance, it is correctly aligned for a long double or long long int), but does not guarantee any larger alignment. For example:
buffer = calloc(100, sizeof(short))
To get a stricter alignment, use the function memalign with the desired alignment. To get an alignment of 256 bytes for example:
buffer = memalign(256, 100 * sizeof(short);
If you are using BIOS memory allocation routines, be sure to pass the alignment factor as the last argument using the syntax that follows:
buffer = MEM_alloc(segid, 100 * sizeof(short), 256); |
See the TMS320C6000 DSP/BIOS Help for more information about BIOS memory allocation routines and the segid parameter in particular.