I have an unmanaged C++ dll that exports the following methods:
ERASURE_API void encode(unsigned char ** inp, unsigned char ** outp,
unsigned int *block_nums, size_t num_block_nums, size_t sz);
ERASURE_API void decode(unsigned char ** inp, unsigned char ** outp,
unsigned int * index, size_t sz);
Size of inp and outp can be as large as 10KB, What would be the best performance way to call these methods from C# managed code?
EDIT: I did the following implementation, and It works, but is it the most efficient way to do this.
C++ :
ERASURE_API void encode_w(unsigned char * inpbuf,int k, unsigned char * outpbuf,
int nfecs, unsigned int * block_nums, size_t num_block_nums, size_t sz)
{
unsigned char ** inp= new unsigned char*[k];
for(i=0;i<k;i++){
inp[i] = inpbuf+i*sz;
}
unsigned char ** outp= new unsigned char *[nfecs];
for(i=0;i<nfecs;i++){
outp[i] =outpbuf+i*sz;
}
encode(inp,outp,block_nums,num_block_nums,sz);
delete [] inp;
delete [] outp;
}
C#:
[DllImport("erasure.dll")]
public static extern void encode_w([In] byte[] inpbuf,int k,[Out] byte[] outpbuf,
int nfecs, uint[] block_nums, int num_block_nums, int sz);