ladybird/Libraries/LibGC/RootVector.cpp
Timothy Flynn 8ec420bc28
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
LibGC: Allow move-assigning RootVector instances
Rule of 5 - we were missing a move-assignment operator, thus all move
assignments resulted in a copy.
2025-04-19 02:03:43 +02:00

35 lines
696 B
C++

/*
* Copyright (c) 2021, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibGC/Heap.h>
#include <LibGC/RootVector.h>
namespace GC {
RootVectorBase::RootVectorBase(Heap& heap)
: m_heap(&heap)
{
m_heap->did_create_root_vector({}, *this);
}
RootVectorBase::~RootVectorBase()
{
m_heap->did_destroy_root_vector({}, *this);
}
void RootVectorBase::assign_heap(Heap* heap)
{
if (m_heap == heap)
return;
m_heap = heap;
// NOTE: IntrusiveList will remove this RootVectorBase from the old heap it was part of.
m_heap->did_create_root_vector({}, *this);
}
}