(
Jump to the original submission)
Thu 30 Oct 2008 10:13:07 AM UTC, comment #7:
I've just checked in the fix.
|
Thu 30 Oct 2008 10:02:13 AM UTC, comment #6:
Hi Florian,
Yes your are damn right.
We use a temporary as return value...
The fact is we must get rid of char* usage
and prefer
std::string
and/or
const std::string&
I'll make that change for the getParameterName.
We could do that safely for ALL internal CERTI API.
I'll open a task for that.
A sidenote to Florian:
May be you can open a Savannah account and get logged
when updating the tracker, this way you'll get follow-up.
|
Thu 30 Oct 2008 07:42:28 AM UTC, comment #5:
Hi Guys,
the codes
return getParameterByHandle(the_handle)->getCName();
return getParameterByHandle(the_handle)->getName().c_str();
looks equal, but there is a small different.
getParameterByHandle(the_handle)->getName() returns a copy (!) of the string in the parameter-object. This copy is a local object in the surrounding Interaction::getParameterName(...) method. The c_str() only returns a pointer IN this new created string-object, which will be deleted after the the closing bracket of the surrounding Method. So the pointer points somewhere to the stack-memory ...
This creates the way throw the method-stacks an empty-string (which was called by Christian and me a Null-string, which is in my eyes a difference from a Null-pointer).
Greetings Florian
|
Wed 29 Oct 2008 07:51:54 PM UTC, comment #4:
I've forget to mention our dev system:
win2k
ms visual 2005
|
Wed 29 Oct 2008 06:54:07 PM UTC, comment #3:
Hi Eric,
today we had the problem to get a string of a
parameter name by invoking the service getParameterName.
E.g. the name of a parameter in the fed file is height.
A sender transmits the parameter to a receiver. The receiver
estimates the parameter string within the callback
receiveINteraction by calling getParameterName(parameterHandle).
This always results in a empty return value.
The small mentioned modification solved our problem.
Was only a small and dirty hack :), perhaps anyone
can test that behaviour too.
This occurs in the current CVS tree and in the last CERTI
release.
So long,
Christian
|
Wed 29 Oct 2008 05:08:35 PM UTC, comment #2:
In fact I'm pretty sure it fixed the bug in some way.
With the Petr modification the returned string won't ever
be a NULL pointer but it may be a null length string
i.e. containing only a '\0'.
However it doesn't look like a "normal" parameter
to be "".
May be there is something I do not understand in this bug
since your code:
return getParameterByHandle(the_handle)->getCName();
is equivalent to the current code:
return getParameterByHandle(the_handle)->getName().c_str();
|
Wed 29 Oct 2008 05:00:36 PM UTC, comment #1:
This may have already been fixed by Petr
modification for handling char* returned value
using "hla_strdup".
Look at related bug 24538
|
Wed 29 Oct 2008 03:54:29 PM UTC, original submission:
Hi all,
just discovered a small bug in rtiAmb, getParameterName() which
returns a Null string.
We have no diff and patching tools here that's why a short description and solution:
We changed a small line within the Interaction.cc file.
const char *
Interaction::getParameterName(ParameterHandle the_handle) const
throw (InteractionParameterNotDefined,
RTIinternalError)
{
return getParameterByHandle(the_handle)->getCName();
}
Many thanks to Florian.
So long,
Christian
|
(Note: upload size limit is set to 16384 kB, after insertion of the required
escape characters.)
Attach File(s):
Comment:
No files currently attached
Depends on the following items
Digest:
bug dependencies.
Items that depend on this one: None found
Follow 7 latest changes.