返回首页

您好,
我已经写了一些C函数看起来像这样。


typedef struct __abc

{

    wchar_t* a;

    wchar_t* b;

}ABC;

 

//I need to pass a pointer to a pointer of this structure to which i will allocate 

//an array of structures as shown



int func(ABC** a)

{

    //need to allocate number of structures at runtime

    *a = (ABC*)malloc(num*sizeof(ABC));

 

    for(i=0;i<num;i++)

    {

        (*a)[i].a = (wchar_t*)malloc(required_size * sizeof(wchar_t));

        //now fill the wchar string

    }

}

 

//now i call this function in c++ as

void some_function()

{

    ABC *pabc;

 

    func(&pabc);

}


现在我的问题是,我需要从C#调用func(农行**)。

因此,我需要做编组。此外,如果我需要传递一个指针(一个缓冲区,其大小仅在运行时被称为),在我的功能在C语言编写的运行时间分配的内存,我可以取回,分配的缓冲区中写入数据

请帮助或引导我如何马歇尔在这种类型的数据。
我已经尝试不同的链接,但他们没有解释如上图所示,这是在运行时分配结构编组。
谢谢。| VinayChoudhary99

回答

评论会员: 时间:2