D
Droopy
I am making a managed C++ wrapper for calling legacy C++ code from C#.
I don't understand what's wrong with following code :
__gc public class SerialBuffer
{
private:
unsigned char __nogc*_buffer;
short _bufferNr;
bool _isUsed;
int _length;
public:
SerialBuffer (short bufferNr);
....
}
__gc public class TrspPortManaged
{
public:
static const short NbSerialBuffers = 128;
TrspPortManaged ();
....
private:
SerialBuffer *_buffers [];
UMTrspPort __nogc *_unmanaged;
....
}
....
TrspPortManaged::TrspPortManaged ()
{
_unmanaged = new UMTrspPort ();
_buffers = new SerialBuffer *[NbSerialBuffers];
SerialBuffer *sb;
for (int i = 1; i <= NbSerialBuffers; i++)
{
sb = new SerialBuffer (i);
_buffers [i - 1] = sb;
}
....
}
In TrspPortManaged constructor, the first iteration in for loop seems OK
(sb _buffer var = 0x07253240, keep the same value in _buffers [0])
The second iteration (i = 2), sb _buffer var = 0x07256ee8, buffer [1]->
_buffer = 0x00000000
What am I doing wrong ?
Thanks in advance for your help.
Droopy.
I don't understand what's wrong with following code :
__gc public class SerialBuffer
{
private:
unsigned char __nogc*_buffer;
short _bufferNr;
bool _isUsed;
int _length;
public:
SerialBuffer (short bufferNr);
....
}
__gc public class TrspPortManaged
{
public:
static const short NbSerialBuffers = 128;
TrspPortManaged ();
....
private:
SerialBuffer *_buffers [];
UMTrspPort __nogc *_unmanaged;
....
}
....
TrspPortManaged::TrspPortManaged ()
{
_unmanaged = new UMTrspPort ();
_buffers = new SerialBuffer *[NbSerialBuffers];
SerialBuffer *sb;
for (int i = 1; i <= NbSerialBuffers; i++)
{
sb = new SerialBuffer (i);
_buffers [i - 1] = sb;
}
....
}
In TrspPortManaged constructor, the first iteration in for loop seems OK
(sb _buffer var = 0x07253240, keep the same value in _buffers [0])
The second iteration (i = 2), sb _buffer var = 0x07256ee8, buffer [1]->
_buffer = 0x00000000
What am I doing wrong ?
Thanks in advance for your help.
Droopy.