While using socket library of c++, I find the following pointer (servinfo) to the library function getaddrinfo. Now I need to know the array size of the pointer servinfo (allocated by the library function) so that I can access each element of the array. How can I get the size of the array servinfo.

struct addrinfo *servinfo;

getaddrinfo(NULL, "3490", &hints,
	&servinfo)) != 0


Here is a quick poor man's method:

int elements = sizeof(serviceinfo) / sizeof(serviceinfo[0]);