0
在Visual C++中,我试图动态分配一些16字节对齐的内存,所以我可以使用需要内存对齐的SSE2函数。现在,我这是怎么分配的内存:boost :: shared_array和对齐的内存分配
boost::shared_array aData(new unsigned char[GetSomeSizeToAllocate()]);
我知道我可以使用_aligned_malloc分配对齐的存储空间,但会引起与提升一个问题,当它试图释放我的记忆?这是代码升压用来释放内存:
template inline void checked_array_delete(T * x)
{
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
(void) sizeof(type_must_be_complete);
delete [] x;
}
Memory free'd by delete must be allocated with new, right? Any tip on how I can get around this?