kernel, luna: Port non-VFS changes over from pull request #22
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
OwnedPtr, SharedPtr: Add operator bool Option, Result: Make try_move_value() non-const since it modifies the Option kernel: Switch to a stack we control for the main task as soon as we leave early boot Heap: Fix GPF caused when making many small allocations Heap: Avoid accessing a block after it's potentially deleted luna: Skip UBSAN.cpp in CMakeLists as that's not implemented yet luna: Use spinlocks in the heap implementation kernel, luna: Move Spinlock.h to luna Option: Use __builtin_launder to ensure that the compiler doesn't label this as UB SharedPtr: Implement make_shared using adopt_shared SharedPtr: Delete ptr on failure in all adopt_shared* functions
This commit is contained in:
parent
6fc02e042a
commit
045efc7046
@ -123,20 +123,6 @@ template <typename T> Result<SharedPtr<T>> adopt_shared(T* ptr)
|
||||
return SharedPtr<T> { ptr, ref_count };
|
||||
}
|
||||
|
||||
// NOTE: ptr is deleted if any of the adopt_shared* functions fail to construct a SharedPtr.
|
||||
template <typename T> Result<SharedPtr<T>> adopt_shared(T* ptr)
|
||||
{
|
||||
using RefCount = __detail::RefCount;
|
||||
|
||||
auto guard = make_scope_guard([ptr] { delete ptr; });
|
||||
|
||||
RefCount* const ref_count = TRY(make<RefCount>());
|
||||
|
||||
guard.deactivate();
|
||||
|
||||
return SharedPtr<T> { ptr, ref_count };
|
||||
}
|
||||
|
||||
template <typename T, class... Args> Result<SharedPtr<T>> make_shared(Args... args)
|
||||
{
|
||||
T* raw_ptr = TRY(make<T>(args...));
|
||||
|
Loading…
Reference in New Issue
Block a user