From 24f18983923cc63706e3c5c8a5db6bb073e7afb7 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 9 Jul 2018 22:05:53 +0300 Subject: Fix memory leak due to complement repository cycles --- bpkg/package.hxx | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'bpkg/package.hxx') diff --git a/bpkg/package.hxx b/bpkg/package.hxx index ea48045..8c8c661 100644 --- a/bpkg/package.hxx +++ b/bpkg/package.hxx @@ -266,16 +266,6 @@ namespace bpkg class repository_fragment { public: - // We use a weak pointer for prerequisite repositories because we could - // have cycles. No cycles in complements, thought. - // - // Note that these point to repositories, not repository fragments. - // - using complements_type = - std::set, compare_lazy_ptr>; - using prerequisites_type = - std::set, compare_lazy_ptr>; - // Repository fragment id is a repository canonical name that identifies // just this fragment (for example, for git it is a canonical name of // the repository URL with the full, non-abbreviated commit id). @@ -291,8 +281,20 @@ namespace bpkg // repository_location location; - complements_type complements; - prerequisites_type prerequisites; + // We use a weak pointer for prerequisite repositories because we could + // have cycles. + // + // Note that we could have cycles for complements via the root repository + // that is the default complement for dir and git repositories (see + // rep-fetch for details), and so we use a weak pointer for complements + // either. + // + // Also note that these point to repositories, not repository fragments. + // + using dependencies = std::set, compare_lazy_ptr>; + + dependencies complements; + dependencies prerequisites; public: explicit -- cgit v1.1