[zypp-devel] Re: [zypp-commit] <sat-solver> master : Move owneship of char* to swig
Hi Klaus, On Mon, 2 Mar 2009, Klaus Kämpf wrote:
ref: refs/heads/master commit dba202c5024fa8c06e3f1f1fe9ffbe2d96bb4e04 Author: Klaus Kämpf
Date: Mon Mar 2 15:25:17 2009 +0100 Move owneship of char* to swig --- a/bindings/repokey.i +++ b/bindings/repokey.i @@ -129,7 +129,7 @@ SV * 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. Ciao, Michael.
* Michael Matz
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@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
participants (2)
-
Klaus Kaempf
-
Michael Matz