由于我已经从我的测试中发现了iPhone的malloc有16个字节对齐。但我不知道它是否保证或只是巧合。
As I've discovered from my tests iPhone's malloc has 16 byte alignment. But I'm not sure whether it is guaranteed or just coincidence.
所以,问题是:什么是对iOS和Android(NDK)使用malloc()时,保证内存对齐
So the question is: what is the guaranteed memory alignment when using malloc() on iOS and Android(NDK)?
的malloc使用C返回一个指向一个内存块,这是适合任何类型的变量一致;这一调整是否或将保持在16个字节甚至不同版本的同一操作系统无法得到保证。 Objective-C的有效基于C,所以应该持有如此那里了。
malloc in C returns a pointer to a block of memory "which is suitably aligned for any kind of variable"; whether this alignment is or will remain at 16 bytes is not guaranteed even for different versions of the same OS. Objective-C is effectively based on C, so that should hold true there too.
如果你的Android NDK是用C或C ++,同样应持有真实存在。
If your Android NDK is written in C or C++, the same should hold true there.