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?