summaryrefslogtreecommitdiff
path: root/modutils/modutils.c
diff options
context:
space:
mode:
authorDenys Vlasenko2015-01-24 22:30:30 +0100
committerDenys Vlasenko2015-01-24 22:30:30 +0100
commitcc70b6f8b6c6441e1c48690c7885700a2d389946 (patch)
tree4ed5b3b75f89ff88d28f639c0911507c07c09c77 /modutils/modutils.c
parent86031a5ffd106b8128f5763d32c273b96875f707 (diff)
downloadbusybox-cc70b6f8b6c6441e1c48690c7885700a2d389946.zip
busybox-cc70b6f8b6c6441e1c48690c7885700a2d389946.tar.gz
depmod: simple memory optimization
function old new delta filename2modname 67 86 +19 parse_module 374 351 -23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'modutils/modutils.c')
-rw-r--r--modutils/modutils.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/modutils/modutils.c b/modutils/modutils.c
index ff79d3f..84300d9 100644
--- a/modutils/modutils.c
+++ b/modutils/modutils.c
@@ -47,13 +47,14 @@ int FAST_FUNC string_to_llist(char *string, llist_t **llist, const char *delim)
char* FAST_FUNC filename2modname(const char *filename, char *modname)
{
+ char local_modname[MODULE_NAME_LEN];
int i;
const char *from;
if (filename == NULL)
return NULL;
if (modname == NULL)
- modname = xmalloc(MODULE_NAME_LEN);
+ modname = local_modname;
// Disabled since otherwise "modprobe dir/name" would work
// as if it is "modprobe name". It is unclear why
// 'basenamization' was here in the first place.
@@ -63,6 +64,9 @@ char* FAST_FUNC filename2modname(const char *filename, char *modname)
modname[i] = (from[i] == '-') ? '_' : from[i];
modname[i] = '\0';
+ if (modname == local_modname)
+ return xstrdup(modname);
+
return modname;
}