Mailinglist Archive: zypp-devel (102 mails)

< Previous Next >
Re: [zypp-devel] Re: [zypp-commit] <sat-solver> master : Move owneship of char* to swig
  • From: Klaus Kaempf <kkaempf@xxxxxxx>
  • Date: Mon, 2 Mar 2009 16:28:46 +0100
  • Message-id: <20090302152846.GA32308@xxxxxxxxxxxxx>
* Michael Matz <matz@xxxxxxx> [Mar 02. 2009 15:50]:
const char *string()
{
Repokey *key = xrepokey_repokey( $self );
- return my_id2str( $self->repo->pool, key->name );
+ return strdup(my_id2str( $self->repo->pool, key->name ));

This change will potentially create a large slowdown and increase memory
use quite a bit as the strings aren't shared anymore but rather are copied
on the fly. That doesn't have to be bad (especially as it's only the
bindings), I just want to make sure that the implications of this are 100%
clear.

Yes, thanks for noting.

solvable2str() returns a temporary string and needs strdup().
However, memory ownership in Swig can only be set per function-name
(here 'string'), affecting all other 'string' functions.

Klaus

P.S. Wow, people actuall read zypp-commit ;-)
--
To unsubscribe, e-mail: zypp-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-devel+help@xxxxxxxxxxxx

< Previous Next >
References