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

Side by Side Diff: fusl/src/network/gethostbyaddr.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 <netdb.h> 3 #include <netdb.h>
4 #include <errno.h> 4 #include <errno.h>
5 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 struct hostent *gethostbyaddr(const void *a, socklen_t l, int af) 7 struct hostent* gethostbyaddr(const void* a, socklen_t l, int af) {
8 { 8 static struct hostent* h;
9 » static struct hostent *h; 9 size_t size = 63;
10 » size_t size = 63; 10 struct hostent* res;
11 » struct hostent *res; 11 int err;
12 » int err; 12 do {
13 » do { 13 free(h);
14 » » free(h); 14 h = malloc(size += size + 1);
15 » » h = malloc(size+=size+1); 15 if (!h) {
16 » » if (!h) { 16 h_errno = NO_RECOVERY;
17 » » » h_errno = NO_RECOVERY; 17 return 0;
18 » » » return 0; 18 }
19 » » } 19 err = gethostbyaddr_r(a, l, af, h, (void*)(h + 1), size - sizeof *h, &res,
20 » » err = gethostbyaddr_r(a, l, af, h, 20 &h_errno);
21 » » » (void *)(h+1), size-sizeof *h, &res, &h_errno); 21 } while (err == ERANGE);
22 » } while (err == ERANGE); 22 return err ? 0 : h;
23 » return err ? 0 : h;
24 } 23 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698