mce16
October 14th, 1999, 09:55 PM
I use a double pointer in my server.exe with one Add method in IMath interface like this
STDMETHODIMP CMath::Add2(long lOp1, long lOp2, long **result)
{
// TODO: Add your implementation code here
**plResult= lOp1 + lOp2; //the program comes here and exit when i step over this line
return S_OK; // the program never come to this line!!
}
// in my client.exe,
//i call my add function after all th necessary initialization
long* result;
result = new long[100];
pMath->Add(200, 300, &result);
cout << result; //This line always print 0x000000
cout <<*result; //client will crash here!
when i debug into the Add function, i noticed as soon as the program enters the function, the next step
it exits from the function without even executing the return S_OK!! I noticed the add operation and whatever following the add operation in the add method is never executed!! why is it so? I tried with a
similar function but using Add(long Op1, long Op2, long* result) instead, and this works fine. Can somebody explain what has happened?
My ATL server.exe consits of only One Interface with One method Add only! What has happened with
the double pointer long** result????
Is it necessary for me to call result = new long[xx]??
STDMETHODIMP CMath::Add2(long lOp1, long lOp2, long **result)
{
// TODO: Add your implementation code here
**plResult= lOp1 + lOp2; //the program comes here and exit when i step over this line
return S_OK; // the program never come to this line!!
}
// in my client.exe,
//i call my add function after all th necessary initialization
long* result;
result = new long[100];
pMath->Add(200, 300, &result);
cout << result; //This line always print 0x000000
cout <<*result; //client will crash here!
when i debug into the Add function, i noticed as soon as the program enters the function, the next step
it exits from the function without even executing the return S_OK!! I noticed the add operation and whatever following the add operation in the add method is never executed!! why is it so? I tried with a
similar function but using Add(long Op1, long Op2, long* result) instead, and this works fine. Can somebody explain what has happened?
My ATL server.exe consits of only One Interface with One method Add only! What has happened with
the double pointer long** result????
Is it necessary for me to call result = new long[xx]??