[zypp-commit] <sat-solver> master : Make memory ownership control more fine-grained
ref: refs/heads/master commit 7877f7660a9ce97e17fd8d36701fa845b5daa289 Author: Klaus Kämpf <kkaempf@suse.de> Date: Mon Mar 2 17:47:00 2009 +0100 Make memory ownership control more fine-grained The %newobject typemap can be specified per-class-and-function and not just per-function (as most other typemaps). Use this to strdup() char pointers returned from solvable2str and dep2str, both using temp memory. --- bindings/relation.i | 1 + bindings/repo.i | 2 +- bindings/repokey.i | 2 +- bindings/satsolver.i | 7 +++---- bindings/solvable.i | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bindings/relation.i b/bindings/relation.i index b76db66..e0a4a5b 100644 --- a/bindings/relation.i +++ b/bindings/relation.i @@ -34,6 +34,7 @@ typedef struct _Relation {} Relation; %rename("__str__") string(); #endif +%newobject Relation::string; const char *string() { return strdup(dep2str( $self->pool, $self->id )); } diff --git a/bindings/repo.i b/bindings/repo.i index d4a06d0..972d2dc 100644 --- a/bindings/repo.i +++ b/bindings/repo.i @@ -26,7 +26,7 @@ typedef struct _Repo {} Repo; #endif const char *string() { - return strdup($self->name); + return $self->name; } /* see also count() below ! */ int size() diff --git a/bindings/repokey.i b/bindings/repokey.i index 8740255..aa2a390 100644 --- a/bindings/repokey.i +++ b/bindings/repokey.i @@ -129,7 +129,7 @@ SV * const char *string() { Repokey *key = xrepokey_repokey( $self ); - return strdup(my_id2str( $self->repo->pool, key->name )); + return my_id2str( $self->repo->pool, key->name ); } } diff --git a/bindings/satsolver.i b/bindings/satsolver.i index 857e442..e630803 100644 --- a/bindings/satsolver.i +++ b/bindings/satsolver.i @@ -285,14 +285,13 @@ dataiterator_value( Dataiterator *di ) %include exception.i -%newobject string; +/*-------------------------------------------------------------*/ +/* types and typemaps */ + %typemap(newfree) char * { free($1); } -/*-------------------------------------------------------------*/ -/* types and typemaps */ - #if defined(SWIGRUBY) /* diff --git a/bindings/solvable.i b/bindings/solvable.i index 5c92e52..0c2ab72 100644 --- a/bindings/solvable.i +++ b/bindings/solvable.i @@ -41,6 +41,7 @@ typedef struct _Solvable {} XSolvable; /* expose XSolvable as 'Solvable' */ void set_vendor(const char *vendor) { xsolvable_solvable($self)->vendor = str2id( $self->pool, vendor, 1 ); } +%newobject XSolvable::string; #if defined(SWIGRUBY) %rename("to_s") string(); #endif -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
Klaus Kämpf