Lost in Space - Memory Allocated By APIsĀ“

Hey...

I am wondering what happens to the memory, allocated for filled structures - returned as pointers, after they are no longer needed.

For Example:

getaddrinfo():

MSDN wrote:
1
2
3
4
5
6
int WSAAPI getaddrinfo(
  __in   const char *nodename,
  __in   const char *servname,
  __in   const struct addrinfo *hints,
  __out  struct addrinfo **res
);


what happens to the memory pointed to by res, when i call WSACleanup() ?...

I dont believe in the redemption of that space due to some Search-and-Destry-action by the Runtime...

wouldnt calls to those functions - if u pass them the needed pointers - cause memory leaks?...

I ever thought i had not to care about this memory allocated by the Win32 API (except from thos functions like HeapAlloc e.g.)...
Last edited on
MSDN also wrote:
Freeing Address Information from Dynamic Allocation
All information returned by the getaddrinfo function pointed to by the res parameter is dynamically allocated, including all addrinfo structures, socket address structures, and canonical host name strings pointed to by addrinfo structures. Memory allocated by a successful call to this function must be released with a subsequent call to freeaddrinfo.


In general you should read up on the function in MSDN - it usually says whether the programmer is responsible for deallocating the buffer, or whether there is a system function (like in the example above) that you call to do the de-allocation.
Last edited on
ok ok ... but what if there is no information about this, like in the example above?...
Topic archived. No new replies allowed.