分配在Visual C对齐的数据(memalign可)+ [英] Allocating aligned data (memalign) in Visual C++
本文介绍了分配在Visual C对齐的数据(memalign可)+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用C ++编写运行在Linux下使用 memalign可
函数分配排列像页边界地区的一个小样机计划。是否有同等功能在Visual C ++?
I have a small prototype program written in C++ running under Linux using the memalign
function to allocate regions aligned to boundaries like pages. Is there an equivalent function in Visual C++?
推荐答案
您正在寻找的 _ aligned_malloc 。请注意,内存必须使用释放 _aligned_free
,并对准被限制为2的幂。
You're looking for _aligned_malloc. Note that memory must be deallocated using _aligned_free
, and that alignment is restricted to powers of 2.
如果您需要更多的灵活性,这不是太难handroll自己的解决方案,它的malloc
取值对齐+字节
内存块的开始。
If you need more flexibility, it's not too hard to handroll your own solution which malloc
s alignment + bytes
memory chunks to start with.
这篇关于分配在Visual C对齐的数据(memalign可)+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文