[omniORB] string problem
Bart van den Eijnden
bart@geodan.nl
Tue, 27 Mar 2001 09:30:18 +0200
Hi Glenn,
I have tried your version but then I get this:
omniORB: WARNING -- method 'GetMnemonic' raised an unexpected
exception (not a CORBA exception).
omniORB: An exception has occured and was caught by tcpSocketMT Worker thread.
omniORB: tcpSocketMTfactory Worker: exit.
In the client I see this, while there are over 200 datasets (it stops at seven
because of the exception):
The mnemonic of dataset 0 is: albos_her_mv4
The mnemonic of dataset 1 is: aps_grid
The mnemonic of dataset 2 is: atrcov_2020_mv4
The mnemonic of dataset 3 is: basis_fysisch_geografische_regi
The mnemonic of dataset 4 is: bebouwde_kom_1930
The mnemonic of dataset 5 is: beh_open_1993_atl
The mnemonic of dataset 6 is: beherst_1993_atl
The mnemonic of dataset 7 is: belem_poly_mv4
Greetings,
Bart
"Glenn A. Hochberg" wrote:
> It looks like the commented out line is what you want, without the other two
> lines:
>
> char* GeoDataset_i::GetMnemonic(int32 index)
> {
> char* ret = CORBA::string_dup(g_SrcMan->SourceMnemonic(index));
> return ret;
> }
>
> The version you have below is leaking the memory you get from string_alloc()
> by overwriting the pointer value with the const char* from the call; you're
> String_var in the client is then going to release it, which is certainly not
> what you want.
>
> Did you try the version above?
>
> -Glenn
>
> Bart van den Eijnden wrote:
>
> > Hi,
> >
> > I have a problem with strings:
> > - the function g_SrcMan->SourceMnemonic(index) results in a const char*
> > -if I call the GetMnemonic function several times and use string_alloc,
> > I only get one record back
> > -if I use the string_dup method instead, I only get a few records, until
> > some kind of buffer is full (?)
> > -if I combine both (I have a memory leak) but it works, then if I call
> > the client twice the second time I don't get anything back anymore. When
> > I restart the server it's ok.
> >
> > Can anyone help?
> >
> > This is the implementation
> > char* GeoDataset_i::GetMnemonic(int32 index)
> > {
> > char* ret = CORBA::string_alloc(80);
> > ret = (char*) g_SrcMan->SourceMnemonic(index);
> > //char* ret = CORBA::string_dup(g_SrcMan->SourceMnemonic(index));
> > return ret;
> > }
> >
> > This is the client:
> > CORBA::String_var ret = gds->GetMnemonic(i);
> > std::cerr << "The mnemonic of dataset " << i << " is: " << (char*) ret
> > << std::endl;
> >
> > --
> > Bart van den Eijnden
> > Geodan SDT BV
> >
> > Vestiging Zuid
> > Buitenhaven 27-A
> > 5211 TP 's-Hertogenbosch
> >
> > Telefoon: 073-6925151
> > Fax: 073-6925150
> > Email: bart@geodan.nl
> > WWW: www.geodan.nl
>
> --
> Glenn A. Hochberg | "Any activity becomes creative when the doer
> AT&T Labs | cares about doing it right, or doing it better."
> gah@research.att.com | -John Updike
--
Bart van den Eijnden
Geodan SDT BV
Vestiging Zuid
Buitenhaven 27-A
5211 TP 's-Hertogenbosch
Telefoon: 073-6925151
Fax: 073-6925150
Email: bart@geodan.nl
WWW: www.geodan.nl