We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
string srs_dns_resolve(string host, int& family) { addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = family;
addrinfo* r = NULL; SrsAutoFree(addrinfo, r); if(getaddrinfo(host.c_str(), NULL, NULL, &r)) { return ""; } char saddr[64]; char* h = (char*)saddr; socklen_t nbh = sizeof(saddr); const int r0 = getnameinfo(r->ai_addr, r->ai_addrlen, h, nbh, NULL, 0, NI_NUMERICHOST); if(!r0) { family = r->ai_family; //freeaddrinfo(r); return string(saddr); } //freeaddrinfo(r); return "";
}
这里使用SrsAutoFree(addrinfo, r); 会导致内存泄漏
The text was updated successfully, but these errors were encountered:
Why?
Sorry, something went wrong.
我用valgrind 测试的时候报getaddrinfo申请的内存没有释放。 但我用freeaddrinfo函数就没有报内存泄漏。
freeaddrinfo 不就是释放吗?...
No branches or pull requests
string srs_dns_resolve(string host, int& family)
{
addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
}
这里使用SrsAutoFree(addrinfo, r); 会导致内存泄漏
The text was updated successfully, but these errors were encountered: