本文介绍了帮助dll中的内存释放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我想访问visual studio 2015使用visual studio 2008在qt中开发的应用程序创建的dll函数。当

I would like access to dll function created by visual studio 2015 from a application developed in qt with visual studio 2008. When

我尝试从应用程序vs2008发布vect(在vs2015的dll中分配一个float数组)我在调试模式下崩溃。

I try to release vect (a float array allocate in dll of vs2015) from application vs2008 I get crash in debug mode.

// dll in vs2015

// dll in vs2015

extern" C" __declspec(dllexport)void function(float ** vect)

{

extern "C" __declspec(dllexport) void function(float ** vect)
{

        ...

        ...

        int numberVertex = 1000;

* vect = new float [numberVertex];

//填充顶点

        int numberVertex=1000;
*vect=new float[numberVertex];
// fill vertex

  &NBSP; &NBSP; &NBSP; for(int i = 0; i< numberVertex; i ++)(* vect)[i] = 3;

        for (int i=0;i<numberVertex;i++) (*vect)[i]=3;

  &NBSP; &NBSP;  

       

}

// vs2008中的应用程序使用QLibrary并调用dll函数

// application in vs2008 use QLibrary and call the dll function

float * vect = NULL

float * vect=NULL

function(& vect);

function(&vect);

delete [] vect; //程序崩溃在调试中,我不会在发布时再试一次。

delete[] vect; // program crash in debug, I don't try again in release.

问题是dll端已知数组元素的数量,因为算法确定了关于输出数组vect。

The problem is that the number of element of array is known on the dll side because the algorithms determinate the dimension about output array vect.

你有没有想过解决这个问题?

Have you idea to solve this problem?

推荐答案


这篇关于帮助dll中的内存释放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 08:05
查看更多