ladybird/Libraries/LibCore/AddressInfoVector.h
Andreas Kling 0fca7d1a6e LibCore: Own addrinfo results without OwnPtr
Store the getaddrinfo result pointer directly in AddressInfoVector and
free it with freeaddrinfo from the destructor. This keeps the special
cleanup logic local to LibCore instead of relying on OwnPtr custom
deleter support.
2026-06-13 22:49:15 +02:00

41 lines
876 B
C++

/*
* Copyright (c) 2022, Lucas Chollet <lucas.chollet@free.fr>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Noncopyable.h>
#include <AK/StdLibExtras.h>
#include <AK/Vector.h>
struct addrinfo;
namespace Core::System {
class AddressInfoVector {
AK_MAKE_NONCOPYABLE(AddressInfoVector);
public:
AddressInfoVector(Vector<struct addrinfo> addresses, struct addrinfo* ptr);
AddressInfoVector(AddressInfoVector&& other);
~AddressInfoVector();
AddressInfoVector& operator=(AddressInfoVector&& other)
{
AddressInfoVector temporary { move(other) };
swap(temporary);
return *this;
}
ReadonlySpan<struct addrinfo> addresses() const { return m_addresses; }
private:
void swap(AddressInfoVector& other);
Vector<struct addrinfo> m_addresses;
struct addrinfo* m_ptr { nullptr };
};
}