Re: "direct exit", crash with no error message?

From: Maury Markowitz (MauryMarkowitz_at_discussions.microsoft.com)
Date: 11/08/04


Date: Mon, 8 Nov 2004 13:37:02 -0800


"Robert Jordan" wrote:

> Are you sure you have to call by ref? You said "pre-malloc-ed". This
> sounds like a non-ref to me

Sounds like I've "duhed" again...

> Please post the C prototype.

Here's the API as documented...

int4 xx_rcvdata (
xx_connect *connection,
void *DataBuf,
int4 maxLen
)

I wrapped it thus...

[DllImport("xx")]
public static extern int xx_rcvdata (
IntPtr connection,
ref byte[] DataBuf,
int maxLen
);

maxLen seems to be an OK number (32->80 in some cases, ~ 2500 in others,
largely what I expect). I wasn't sure if the void* should be a int[] or a
byte[], the example code treats it as a char*, but I tried both with the same
results.

I called the code like this...

byte[] buffer = new byte[maxLen];
int ret = xx_rcvdata(conn, ref buffer, maxLen);

I also got bored and declared it all unsafe and used a stackalloc, which
worked. So I guess it's just another wrapping problem.

Maury



Relevant Pages


Loading