1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:27:43 +00:00

AK+Everywhere: Move custom deleter capability to OwnPtr

`OwnPtrWithCustomDeleter` was a decorator which provided the ability
to add a custom deleter to `OwnPtr` by wrapping and taking the deleter
as a run-time argument to the constructor. This solution means that no
additional space is needed for the `OwnPtr` because it doesn't need to
store a pointer to the deleter, but comes at the cost of having an
extra type that stores a pointer for every instance.

This logic is moved directly into `OwnPtr` by adding a template
argument that is defaulted to the default deleter for the type. This
means that the type itself stores the pointer to the deleter instead
of every instance and adds some type safety by encoding the deleter in
the type itself instead of taking a run-time argument.
This commit is contained in:
Lenny Maiorani 2022-12-15 20:51:55 -07:00 committed by Tim Flynn
parent 53133b4359
commit f2336d0144
12 changed files with 74 additions and 63 deletions

View file

@ -1334,11 +1334,7 @@ ErrorOr<AddressInfoVector> getaddrinfo(char const* nodename, char const* servnam
for (auto* result = results; result != nullptr; result = result->ai_next)
TRY(addresses.try_append(*result));
return AddressInfoVector { move(addresses), results,
[](struct addrinfo* ptr) {
if (ptr)
::freeaddrinfo(ptr);
} };
return AddressInfoVector { move(addresses), results };
}
ErrorOr<void> getsockopt(int sockfd, int level, int option, void* value, socklen_t* value_size)