Schmidt Thomas
2009-01-18 14:15:23 UTC
Hi,
when writing some pull-event supplier I think I've to return a
dynamically allocated Any pointer. Who has to take care of freeing
this variable? F.e. some code fragments from my example server
program "SinusGenerator":
CORBA::Any *SinusGenerator_impl::pull()
{
CORBA::Any &theValue = *new CORBA::Any; // GNU raises bad_alloc
() in case
CORBA::ULong currentPos = currentSamplePosPostInc();
DataPoint dp = { currentPos, _curveSamples[currentPos] };
theValue <<= dp;
return &theValue;
} /* pull() */
while DataPoint is defined as follows (DataPoint.idl):
struct DataPoint
{
unsigned long x;
double y;
} /* struct DataPoint */;
Returning some statically allocated variable in the above example
seems not the best idea when writing reentrant code.
Both parts, server and client, of my little experimental environment
work well. But I wonder who will free the variable 'theValue'.
Thanks Thomas
--
Thomas Schmidt
Schneiderstr. 16
D-29575 Altenmedingen
Phone: +49-5807-209976
Cellular: +49-172-3011505
Skype: ThCSchmidt
Email: ***@vodafone.de
PGP: Key-ID: 0x810B6206
when writing some pull-event supplier I think I've to return a
dynamically allocated Any pointer. Who has to take care of freeing
this variable? F.e. some code fragments from my example server
program "SinusGenerator":
CORBA::Any *SinusGenerator_impl::pull()
{
CORBA::Any &theValue = *new CORBA::Any; // GNU raises bad_alloc
() in case
CORBA::ULong currentPos = currentSamplePosPostInc();
DataPoint dp = { currentPos, _curveSamples[currentPos] };
theValue <<= dp;
return &theValue;
} /* pull() */
while DataPoint is defined as follows (DataPoint.idl):
struct DataPoint
{
unsigned long x;
double y;
} /* struct DataPoint */;
Returning some statically allocated variable in the above example
seems not the best idea when writing reentrant code.
Both parts, server and client, of my little experimental environment
work well. But I wonder who will free the variable 'theValue'.
Thanks Thomas
--
Thomas Schmidt
Schneiderstr. 16
D-29575 Altenmedingen
Phone: +49-5807-209976
Cellular: +49-172-3011505
Skype: ThCSchmidt
Email: ***@vodafone.de
PGP: Key-ID: 0x810B6206