Ip::Address::applyMask(const unsigned int cidrMask, int mtype)
{
uint8_t clearbits = 0;
- uint8_t* p = NULL;
+ uint8_t* p = nullptr;
// validation and short-cuts.
if (cidrMask > 128)
}
int err = 0;
- struct addrinfo *res = NULL;
- if ( (err = getaddrinfo(s, NULL, &want, &res)) != 0) {
+ struct addrinfo *res = nullptr;
+ if ( (err = getaddrinfo(s, nullptr, &want, &res)) != 0) {
debugs(14,3, "Given Non-IP '" << s << "': " << gai_strerror(err) );
/* free the memory getaddrinfo() dynamically allocated. */
if (res)
break;
maybeIpv4 = maybeIpv4->ai_next;
}
- if (maybeIpv4 != NULL)
+ if (maybeIpv4 != nullptr)
res = maybeIpv4;
// else IPv6-only host, let the caller deal with first-IP anyway.
}
Ip::Address::operator =(const struct hostent &s)
{
- struct in_addr* ipv4 = NULL;
+ struct in_addr* ipv4 = nullptr;
- struct in6_addr* ipv6 = NULL;
+ struct in6_addr* ipv6 = nullptr;
//struct hostent {
// char *h_name; /* official name of host */
Ip::Address::operator =(const struct addrinfo &s)
{
- struct sockaddr_in* ipv4 = NULL;
+ struct sockaddr_in* ipv4 = nullptr;
- struct sockaddr_in6* ipv6 = NULL;
+ struct sockaddr_in6* ipv6 = nullptr;
//struct addrinfo {
// int ai_flags; /* input flags */
default:
// attempt to handle partially initialised addrinfo.
// such as those where data only comes from getsockopt()
- if (s.ai_addr != NULL) {
+ if (s.ai_addr != nullptr) {
if (s.ai_addrlen == sizeof(struct sockaddr_in6)) {
operator=(*((struct sockaddr_in6*)s.ai_addr));
return true;
void
Ip::Address::getAddrInfo(struct addrinfo *&dst, int force) const
{
- if (dst == NULL) {
+ if (dst == nullptr) {
dst = new addrinfo;
}
void
Ip::Address::InitAddr(struct addrinfo *&ai)
{
- if (ai == NULL) {
+ if (ai == nullptr) {
ai = new addrinfo;
memset(ai,0,sizeof(struct addrinfo));
}
void
Ip::Address::FreeAddr(struct addrinfo *&ai)
{
- if (ai == NULL) return;
+ if (ai == nullptr) return;
if (ai->ai_addr) delete ai->ai_addr;
- ai->ai_addr = NULL;
+ ai->ai_addr = nullptr;
ai->ai_addrlen = 0;
// NP: name fields are NOT allocated at present.
delete ai;
- ai = NULL;
+ ai = nullptr;
}
int
Ip::Address::toStr(char* buf, const unsigned int blen, int force) const
{
// Ensure we have a buffer.
- if (buf == NULL) {
- return NULL;
+ if (buf == nullptr) {
+ return nullptr;
}
/* some external code may have blindly memset a parent. */
// Ensure we have a buffer.
- if (buf == NULL) {
- return NULL;
+ if (buf == nullptr) {
+ return nullptr;
}
p += toHostStr(p, blen);
void
Ip::Address::getSockAddr(struct sockaddr_storage &addr, const int family) const
{
- struct sockaddr_in *sin = NULL;
+ struct sockaddr_in *sin = nullptr;
if ( family == AF_INET && !isIPv4()) {
// TODO INET6: caller using the wrong socket type!