N
nicgendron
Hi all,
I have a function that I registered to return an OPER array ('P' retur
type).
In all example I saw, here is the way it is done
Code
-------------------
OPER* __stdcall MyFunc(...)
{
static OPER sRet;
static OPER sArray[numberOfElements];
...
//do some calculation
...
// fill sArray
// affect sArray to sRet and set type of sRet to be an array
return &sRet;
}
-------------------
That works very fine but I have two questions :
1 - With this way I can return something in 'numberOfElements' cells
For exemple, if 'numberOfElements' is 3, I can return value in A1
A2 and A3
But what if I need to return value in A1, A2, A3, B1, B2, B3 (i.e
returning an array of 3 by 3)
2 - What if I don't know the number of element that I have to return.
Can I just do a 'malloc' of an array and then forget it ? ...
don't think so. I'll need to 'free' this at some moment. In othe
word, is there a way to replace static variable without having memor
leaks ?
Thanks a lot
Ni
I have a function that I registered to return an OPER array ('P' retur
type).
In all example I saw, here is the way it is done
Code
-------------------
OPER* __stdcall MyFunc(...)
{
static OPER sRet;
static OPER sArray[numberOfElements];
...
//do some calculation
...
// fill sArray
// affect sArray to sRet and set type of sRet to be an array
return &sRet;
}
-------------------
That works very fine but I have two questions :
1 - With this way I can return something in 'numberOfElements' cells
For exemple, if 'numberOfElements' is 3, I can return value in A1
A2 and A3
But what if I need to return value in A1, A2, A3, B1, B2, B3 (i.e
returning an array of 3 by 3)
2 - What if I don't know the number of element that I have to return.
Can I just do a 'malloc' of an array and then forget it ? ...
don't think so. I'll need to 'free' this at some moment. In othe
word, is there a way to replace static variable without having memor
leaks ?
Thanks a lot
Ni