freeaddrinfo Function

The freeaddrinfofunction frees address information that the getaddrinfo function dynamically allocates in addrinfo structures.

Syntax

void freeaddrinfo(
  __in  struct addrinfo *ai
);

Parameter

  • ai [in]
    A pointer to the addrinfo structure or linked list of addrinfo structures to be freed. All dynamic storage pointed to within the addrinfo structure or structures is also freed.

Rückgabewert

Funktion gibt keinen Wert zurück.

Hinweise

The freeaddrinfo function frees addrinfo structures dynamically allocated by the ANSI getaddrinfo function. The freeaddrinfo function frees the initial addrinfo structure pointed to in the ai parameter, including any buffers to which structure members point, then continues freeing any addrinfo structures linked by the ai_next member of the addrinfo structure. The freeaddrinfo function continues freeing linked structures until a NULL ai_next member is encountered.

Macros in the Winsock header file define a mixed-case function name of FreeAddrInfo and an ADDRINFOT structure. This FreeAddrInfo function should be called with the ai parameter of a pointer of type ADDRINFOT. When UNICODE or _UNICODE is not defined, FreeAddrInfo is defined to freeaddrinfo, the ANSI version of the function, and ADDRINFOT is defined to the addrinfo structure. When UNICODE or _UNICODE is defined, FreeAddrInfo is defined to FreeAddrInfoW, the Unicode version of the function, and ADDRINFOT is defined to the addrinfoW structure.

Support for freeaddrinfo on earlier versions of Windows

The freeaddrinfo function was added to the Ws2_32.dll on Windows XP and later. To execute an application using this function on earlier versions of Windows (Windows 2000, Windows NT, and Windows Me/98/95), then you must include the Ws2tcpip.h file and also include the Wspiapi.h file. When the Wspiapi.h include file is added, the freeaddrinfo function is defined to the WspiapiFreeAddrInfo inline function in the Wspiapi.h file. At runtime, the WspiapiFreeAddrInfo function is implemented in such a way that if the Ws2_32.dll or the Wship6.dll (the file containing freeaddrinfo in the IPv6 Technology Preview for Windows 2000) does not include freeaddrinfo, then a version of freeaddrinfo is implemented inline based on code in the Wspiapi.h header file. This inline code will be used on older Windows platforms that do not natively support the freeaddrinfo function.

The FreeAddrInfoW function is the Unicode version of freeaddrinfo. The FreeAddrInfoW function was added to the Ws2_32.dll in Windows XP mit Service Pack 2 (SP2). The FreeAddrInfoW function cannot be used on versions of Windows earlier than Windows XP mit SP2.

Anforderungen

Mindestens unterstützter Client

Windows 2000 Professional

Mindestens unterstützter Server

Windows 2000 Server

Header

Ws2tcpip.h; Ws2tcpip.h on Windows 2000 (include Wspiapi.h)

DLL

Ws2_32.dll

Siehe auch

addrinfo

addrinfoW

FreeAddrInfoW

getaddrinfo

GetAddrInfoW

Winsock Functions