在我的C++/CLI代码中,我有这段代码:
array<Byte>^ out_buf = gcnew array<Byte>(stream_size);
Marshal::Copy(IntPtr(buf), out_buf, 0, Int32(stream_size));
System::IO::MemoryStream^ stream = gcnew MemoryStream(out_buf);
MemoryStream(out_buf)
中,MemoryStream
会重新分配内存还是只接管out_buf
的所有权呢?
如果MemoryStream
会重新分配内存,那么有没有办法将本地缓冲区转换为MemoryStream
?