jsocketpp 1.0
A cross-platform C++20 socket library.
Loading...
Searching...
No Matches
jsocketpp::internal::AddrinfoDeleter Struct Reference

Custom deleter for addrinfo* pointers to support RAII-style cleanup. More...

#include <common.hpp>

Public Member Functions

void operator() (addrinfo *p) const noexcept
 Deletes an addrinfo* by calling freeaddrinfo().

Detailed Description

Custom deleter for addrinfo* pointers to support RAII-style cleanup.

This deleter is intended for use with std::unique_ptr<addrinfo, AddrinfoDeleter>, enabling automatic cleanup of dynamically allocated addrinfo structures returned by getaddrinfo(). When the smart pointer goes out of scope, freeaddrinfo() will be called automatically to release associated memory.

Example

addrinfo* raw = nullptr;
getaddrinfo("example.com", "80", &hints, &raw);
AddrinfoPtr info(raw); // Automatically cleaned up
std::unique_ptr< addrinfo, AddrinfoDeleter > AddrinfoPtr
Smart pointer that manages addrinfo* resources using AddrinfoDeleter.
Definition common.hpp:819
See also
AddrinfoPtr
getaddrinfo()
freeaddrinfo()

Member Function Documentation

◆ operator()()

void jsocketpp::internal::AddrinfoDeleter::operator() ( addrinfo * p) const
inlinenoexcept

Deletes an addrinfo* by calling freeaddrinfo().

Parameters
[in]pPointer to an addrinfo structure to be deallocated.

The documentation for this struct was generated from the following file: