Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#interop:在非托管结构中处理指针数组_C#_Pointers_Interop_Unmanaged - Fatal编程技术网

C#interop:在非托管结构中处理指针数组

C#interop:在非托管结构中处理指针数组,c#,pointers,interop,unmanaged,C#,Pointers,Interop,Unmanaged,我正在包装一些对非托管Aubio库dll(Aubio.org)的调用, 我想知道处理Aubio样本缓冲区的好方法是什么 它的定义如下: // Buffer for real values struct _fvec_t { uint length; // length of buffer uint channels; // number of channels float **data; // data array of size [length] * [channels]

我正在包装一些对非托管Aubio库dll(Aubio.org)的调用, 我想知道处理Aubio样本缓冲区的好方法是什么

它的定义如下:

// Buffer for real values
struct _fvec_t {
  uint length;    // length of buffer
  uint channels;  // number of channels
  float **data;   // data array of size [length] * [channels]
};
Aubio为我创建了结构,正确设置了datamembers,因此我得到了一个IntPtr。 我需要从我的C#代码读取/写入数据指针

for(int chan_idx=0;chan_idx对于(int i=0;i我想您可以定义一个托管结构和PtrToStructure,然后修改StructureToPtr(返回到同一位置),但可能同样简单,因为内存已经分配完毕,只需读取数组的intptr,然后使用Copy将浮点数组写入其中:


这只是封送方法的一个想法。复制方法:如果是指针数组,则可以将数据指针封送到IntPtr数组,然后分别封送每个IntPtr。但不确定这是否是最好的主意。我同意OregonGhost的观点。或者在C#中使用不安全的代码和“真实”指针。
for (int chan_idx = 0; chan_idx < my_fvec.channels; ++chan_idx)
    for (int i=0; i<something; i++)
       my_fvec.data[chan_idx][i] = SomeRandomValue();