MCPcopy Create free account
hub / github.com/RsyncProject/rsync / alloc_entry

Function alloc_entry

lib/getaddrinfo.c:120–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120static struct addrinfo *alloc_entry(const struct addrinfo *hints,
121 struct in_addr ip,
122 unsigned short port)
123{
124 struct sockaddr_in *psin = NULL;
125 struct addrinfo *ai = SMB_MALLOC(sizeof(*ai));
126
127 if (!ai) {
128 return NULL;
129 }
130 memset(ai, '\0', sizeof(*ai));
131
132 psin = SMB_MALLOC(sizeof(*psin));
133 if (!psin) {
134 free(ai);
135 return NULL;
136 }
137
138 memset(psin, '\0', sizeof(*psin));
139
140 psin->sin_family = AF_INET;
141 psin->sin_port = htons(port);
142 psin->sin_addr = ip;
143
144 ai->ai_flags = 0;
145 ai->ai_family = AF_INET;
146 ai->ai_socktype = hints->ai_socktype;
147 ai->ai_protocol = hints->ai_protocol;
148 ai->ai_addrlen = sizeof(*psin);
149 ai->ai_addr = (struct sockaddr *) psin;
150 ai->ai_canonname = NULL;
151 ai->ai_next = NULL;
152
153 return ai;
154}
155
156/*
157 * get address info for a single ipv4 address.

Callers 2

getaddr_info_single_addrFunction · 0.85
getaddr_info_nameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected