diff options
author | Matt Kraai | 2001-02-01 19:21:20 +0000 |
---|---|---|
committer | Matt Kraai | 2001-02-01 19:21:20 +0000 |
commit | f2cc2762bb273fbabe8c2eadeb3b8669550582f0 (patch) | |
tree | e1bc52067709069328f058b80b9a1273c7c240d2 /utility.c | |
parent | 05e782ddd3dc58245c889529bb8aeeaddf24bf71 (diff) | |
download | busybox-f2cc2762bb273fbabe8c2eadeb3b8669550582f0.zip busybox-f2cc2762bb273fbabe8c2eadeb3b8669550582f0.tar.gz |
Create find_applet_by_name function. Save 32 bytes.
Diffstat (limited to 'utility.c')
-rw-r--r-- | utility.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -1691,12 +1691,20 @@ FILE *xfopen(const char *path, const char *mode) } #endif -int applet_name_compare(const void *x, const void *y) +static int applet_name_compare(const void *x, const void *y) { - const struct BB_applet *applet1 = x; - const struct BB_applet *applet2 = y; + const char *name = x; + const struct BB_applet *applet = y; - return strcmp(applet1->name, applet2->name); + return strcmp(name, applet->name); +} + +extern size_t NUM_APPLETS; + +struct BB_applet *find_applet_by_name(const char *name) +{ + return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet), + applet_name_compare); } #if defined BB_DD || defined BB_TAIL |