summaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorMatt Kraai2001-02-01 19:21:20 +0000
committerMatt Kraai2001-02-01 19:21:20 +0000
commitf2cc2762bb273fbabe8c2eadeb3b8669550582f0 (patch)
treee1bc52067709069328f058b80b9a1273c7c240d2 /utility.c
parent05e782ddd3dc58245c889529bb8aeeaddf24bf71 (diff)
downloadbusybox-f2cc2762bb273fbabe8c2eadeb3b8669550582f0.zip
busybox-f2cc2762bb273fbabe8c2eadeb3b8669550582f0.tar.gz
Create find_applet_by_name function. Save 32 bytes.
Diffstat (limited to 'utility.c')
-rw-r--r--utility.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/utility.c b/utility.c
index 0a0e652..69403c8 100644
--- a/utility.c
+++ b/utility.c
@@ -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