Access violation when using pin_ptr?

送分小仙女□ 提交于 2019-12-05 19:16:54

When a pinning pointer goes out of scope, the object is no longer considered pinned, unless there are other pinning pointers pointing to or into the object. You do not have to explicitly unpin a pointer.

As the docs say, pin_ptr only pins the target while it is in scope. This means that after each iteration of the following loop, the object is unpinned, rendering the pointers that were stored useless.

for(i = 0; i < modelsNum; i++)
{
    pin_ptr<unsigned char> ptr = &modelsBuffer[i][0];
    models[i] = (float*) ptr;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!