pin-ptr

Access violation when using pin_ptr?

拈花ヽ惹草 提交于 2020-01-02 07:23:28
问题 When I use pin_ptr to pass an array in native c code, I get access violation. The code is as bellow: array<float>^ LogLikelihoodScore(array<array<unsigned char>^>^ modelsBuffer , array<float>^ featuresArray, int numberOfFrames) { int i, j, modelsNum = modelsBuffer->Length, len; float **models = (float**) malloc(modelsNum * sizeof(void*)); for(i = 0; i < modelsNum; i++) { pin_ptr<unsigned char> ptr = &modelsBuffer[i][0]; models[i] = (float*) ptr; } array<float>^ scores = gcnew array<float>

Access violation when using pin_ptr?

送分小仙女□ 提交于 2019-12-05 19:16:54
When I use pin_ptr to pass an array in native c code, I get access violation. The code is as bellow: array<float>^ LogLikelihoodScore(array<array<unsigned char>^>^ modelsBuffer , array<float>^ featuresArray, int numberOfFrames) { int i, j, modelsNum = modelsBuffer->Length, len; float **models = (float**) malloc(modelsNum * sizeof(void*)); for(i = 0; i < modelsNum; i++) { pin_ptr<unsigned char> ptr = &modelsBuffer[i][0]; models[i] = (float*) ptr; } array<float>^ scores = gcnew array<float>(modelsNum); pin_ptr<float> scoresPtr = &scores[0]; pin_ptr<float> featuresPtr = &featuresArray[0]; char*