Why would you have to call `new`? Why would `malloc()` not work here?
std::unique_ptr<ADDRINFOEXW, addrinfo_deleter> holder;
ADDRINFOEXW hint = { .ai_family = AF_UNSPEC };
if (const auto result = GetAddrInfoExW(
sHost
, nullptr
, NS_ALL
, nullptr
, &hint
, std::out_ptr(holder)
, nullptr
, nullptr
, nullptr
, nullptr); result != ERROR_SUCCESS) {
// print error here
}But having malloc/free cross a library boundary (that is library A malloc and wants the caller in a different library to call free) is also a code smell in general and potentially very problematic. So you'll be generally doing custom deleters regardless