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

Side by Side Diff: fusl/src/stdlib/bsearch.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 #include <stdlib.h> 1 #include <stdlib.h>
2 2
3 void *bsearch(const void *key, const void *base, size_t nel, size_t width, int ( *cmp)(const void *, const void *)) 3 void* bsearch(const void* key,
4 { 4 const void* base,
5 » void *try; 5 size_t nel,
6 » int sign; 6 size_t width,
7 » while (nel > 0) { 7 int (*cmp)(const void*, const void*)) {
8 » » try = (char *)base + width*(nel/2); 8 void* try
9 » » sign = cmp(key, try); 9 ;
10 » » if (!sign) return try; 10 int sign;
11 » » else if (nel == 1) break; 11 while (nel > 0) {
12 » » else if (sign < 0) 12 try
13 » » » nel /= 2; 13 = (char*)base + width * (nel / 2);
14 » » else { 14 sign = cmp(key, try);
15 » » » base = try; 15 if (!sign)
16 » » » nel -= nel/2; 16 return try
17 » » } 17 ;
18 » } 18 else if (nel == 1)
19 » return NULL; 19 break;
20 else if (sign < 0)
21 nel /= 2;
22 else {
23 base = try
24 ;
25 nel -= nel / 2;
26 }
27 }
28 return NULL;
20 } 29 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698