diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-01-24 22:30:30 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-01-24 22:30:30 +0100 |
commit | cc70b6f8b6c6441e1c48690c7885700a2d389946 (patch) | |
tree | 4ed5b3b75f89ff88d28f639c0911507c07c09c77 /modutils/modutils.c | |
parent | 86031a5ffd106b8128f5763d32c273b96875f707 (diff) | |
download | busybox-w32-cc70b6f8b6c6441e1c48690c7885700a2d389946.tar.gz busybox-w32-cc70b6f8b6c6441e1c48690c7885700a2d389946.tar.bz2 busybox-w32-cc70b6f8b6c6441e1c48690c7885700a2d389946.zip |
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.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/modutils/modutils.c b/modutils/modutils.c index ff79d3fac..84300d931 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) | |||
47 | 47 | ||
48 | char* FAST_FUNC filename2modname(const char *filename, char *modname) | 48 | char* FAST_FUNC filename2modname(const char *filename, char *modname) |
49 | { | 49 | { |
50 | char local_modname[MODULE_NAME_LEN]; | ||
50 | int i; | 51 | int i; |
51 | const char *from; | 52 | const char *from; |
52 | 53 | ||
53 | if (filename == NULL) | 54 | if (filename == NULL) |
54 | return NULL; | 55 | return NULL; |
55 | if (modname == NULL) | 56 | if (modname == NULL) |
56 | modname = xmalloc(MODULE_NAME_LEN); | 57 | modname = local_modname; |
57 | // Disabled since otherwise "modprobe dir/name" would work | 58 | // Disabled since otherwise "modprobe dir/name" would work |
58 | // as if it is "modprobe name". It is unclear why | 59 | // as if it is "modprobe name". It is unclear why |
59 | // 'basenamization' was here in the first place. | 60 | // 'basenamization' was here in the first place. |
@@ -63,6 +64,9 @@ char* FAST_FUNC filename2modname(const char *filename, char *modname) | |||
63 | modname[i] = (from[i] == '-') ? '_' : from[i]; | 64 | modname[i] = (from[i] == '-') ? '_' : from[i]; |
64 | modname[i] = '\0'; | 65 | modname[i] = '\0'; |
65 | 66 | ||
67 | if (modname == local_modname) | ||
68 | return xstrdup(modname); | ||
69 | |||
66 | return modname; | 70 | return modname; |
67 | } | 71 | } |
68 | 72 | ||