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

Side by Side Diff: fusl/src/search/lsearch.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 <search.h> 1 #include <search.h>
2 #include <string.h> 2 #include <string.h>
3 3
4 void *lsearch(const void *key, void *base, size_t *nelp, size_t width, 4 void* lsearch(const void* key,
5 » int (*compar)(const void *, const void *)) 5 void* base,
6 { 6 size_t* nelp,
7 » char (*p)[width] = base; 7 size_t width,
8 » size_t n = *nelp; 8 int (*compar)(const void*, const void*)) {
9 » size_t i; 9 char(*p)[width] = base;
10 size_t n = *nelp;
11 size_t i;
10 12
11 » for (i = 0; i < n; i++) 13 for (i = 0; i < n; i++)
12 » » if (compar(p[i], key) == 0) 14 if (compar(p[i], key) == 0)
13 » » » return p[i]; 15 return p[i];
14 » *nelp = n+1; 16 *nelp = n + 1;
15 » return memcpy(p[n], key, width); 17 return memcpy(p[n], key, width);
16 } 18 }
17 19
18 void *lfind(const void *key, const void *base, size_t *nelp, 20 void* lfind(const void* key,
19 » size_t width, int (*compar)(const void *, const void *)) 21 const void* base,
20 { 22 size_t* nelp,
21 » char (*p)[width] = (void *)base; 23 size_t width,
22 » size_t n = *nelp; 24 int (*compar)(const void*, const void*)) {
23 » size_t i; 25 char(*p)[width] = (void*)base;
26 size_t n = *nelp;
27 size_t i;
24 28
25 » for (i = 0; i < n; i++) 29 for (i = 0; i < n; i++)
26 » » if (compar(p[i], key) == 0) 30 if (compar(p[i], key) == 0)
27 » » » return p[i]; 31 return p[i];
28 » return 0; 32 return 0;
29 } 33 }
30
31
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698