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

Side by Side Diff: fusl/src/search/lsearch.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « fusl/src/search/insque.c ('k') | fusl/src/search/tdestroy.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include <search.h>
2 #include <string.h>
3
4 void *lsearch(const void *key, void *base, size_t *nelp, size_t width,
5 int (*compar)(const void *, const void *))
6 {
7 char (*p)[width] = base;
8 size_t n = *nelp;
9 size_t i;
10
11 for (i = 0; i < n; i++)
12 if (compar(p[i], key) == 0)
13 return p[i];
14 *nelp = n+1;
15 return memcpy(p[n], key, width);
16 }
17
18 void *lfind(const void *key, const void *base, size_t *nelp,
19 size_t width, int (*compar)(const void *, const void *))
20 {
21 char (*p)[width] = (void *)base;
22 size_t n = *nelp;
23 size_t i;
24
25 for (i = 0; i < n; i++)
26 if (compar(p[i], key) == 0)
27 return p[i];
28 return 0;
29 }
30
31
OLDNEW
« no previous file with comments | « fusl/src/search/insque.c ('k') | fusl/src/search/tdestroy.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698