Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: fusl/src/network/gethostbyname2.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #define _GNU_SOURCE 1 #define _GNU_SOURCE
2 2
3 #include <sys/socket.h> 3 #include <sys/socket.h>
4 #include <netdb.h> 4 #include <netdb.h>
5 #include <errno.h> 5 #include <errno.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 struct hostent *gethostbyname2(const char *name, int af) 8 struct hostent* gethostbyname2(const char* name, int af) {
9 { 9 static struct hostent* h;
10 » static struct hostent *h; 10 size_t size = 63;
11 » size_t size = 63; 11 struct hostent* res;
12 » struct hostent *res; 12 int err;
13 » int err; 13 do {
14 » do { 14 free(h);
15 » » free(h); 15 h = malloc(size += size + 1);
16 » » h = malloc(size+=size+1); 16 if (!h) {
17 » » if (!h) { 17 h_errno = NO_RECOVERY;
18 » » » h_errno = NO_RECOVERY; 18 return 0;
19 » » » return 0; 19 }
20 » » } 20 err = gethostbyname2_r(name, af, h, (void*)(h + 1), size - sizeof *h, &res,
21 » » err = gethostbyname2_r(name, af, h, 21 &h_errno);
22 » » » (void *)(h+1), size-sizeof *h, &res, &h_errno); 22 } while (err == ERANGE);
23 » } while (err == ERANGE); 23 return err ? 0 : h;
24 » return err ? 0 : h;
25 } 24 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698