aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-06 01:37:27 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-06 01:37:27 +0000
commit7a56cfc21ba06ece6ff30627bb634be1b7b7a1f9 (patch)
treef375568a457d1b4a09b323a88fbdcfbe5c3786a0
parent4aa4eb9234c05fac50799659bc37a600335755ef (diff)
downloadpaludis-7a56cfc21ba06ece6ff30627bb634be1b7b7a1f9.tar.gz
paludis-7a56cfc21ba06ece6ff30627bb634be1b7b7a1f9.tar.xz
(ruby) Don't garbage collect child DepSpecs when we still need them.
-rw-r--r--ruby/dep_spec.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index b758ee3..2528514 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -91,8 +91,19 @@ namespace
virtual const tr1::shared_ptr<const DepSpec> base_spec() const = 0;
virtual const tr1::shared_ptr<const Children> children() const = 0;
+
+ static void mark(tr1::shared_ptr<const WrappedSpecBase> *);
};
+ void
+ WrappedSpecBase::mark(tr1::shared_ptr<const WrappedSpecBase> * ptr)
+ {
+ tr1::shared_ptr<const Children> children((*ptr)->children());
+ for (Children::const_iterator it(children->begin()),
+ it_end(children->end()); it_end != it; ++it)
+ rb_gc_mark(it->first);
+ }
+
template <typename T_>
class WrappedSpec :
public WrappedSpecBase,
@@ -203,7 +214,7 @@ namespace
{
ptr = new tr1::shared_ptr<const WrappedSpecBase>(
(new WrappedSpec<UseDepSpec>(tr1::static_pointer_cast<UseDepSpec>(spec.clone())))->add_children(cur, end));
- value = Data_Wrap_Struct(c_use_dep_spec, 0, &Common<tr1::shared_ptr<const WrappedSpecBase> >::free, ptr);
+ value = Data_Wrap_Struct(c_use_dep_spec, &WrappedSpecBase::mark, &Common<tr1::shared_ptr<const WrappedSpecBase> >::free, ptr);
}
void visit_sequence(const AllDepSpec & spec,
@@ -212,7 +223,7 @@ namespace
{
ptr = new tr1::shared_ptr<const WrappedSpecBase>(
(new WrappedSpec<AllDepSpec>(tr1::static_pointer_cast<AllDepSpec>(spec.clone())))->add_children(cur, end));
- value = Data_Wrap_Struct(c_all_dep_spec, 0, &Common<tr1::shared_ptr<const WrappedSpecBase> >::free, ptr);
+ value = Data_Wrap_Struct(c_all_dep_spec, &WrappedSpecBase::mark, &Common<tr1::shared_ptr<const WrappedSpecBase> >::free, ptr);
}
void visit_sequence(const AnyDepSpec & spec,
@@ -221,7 +232,7 @@ namespace
{
ptr = new tr1::shared_ptr<const WrappedSpecBase>(
(new WrappedSpec<AnyDepSpec>(tr1::static_pointer_cast<AnyDepSpec>(spec.clone())))->add_children(cur, end));
- value = Data_Wrap_Struct(c_any_dep_spec, 0, &Common<tr1::shared_ptr<const WrappedSpecBase> >::free, ptr);
+ value = Data_Wrap_Struct(c_any_dep_spec, &WrappedSpecBase::mark, &Common<tr1::shared_ptr<const WrappedSpecBase> >::free, ptr);
}
};