From: Yousong Zhou Date: Thu, 23 Feb 2017 03:04:50 +0000 (+0800) Subject: kmodloader: don't store aliases info in struct module X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3dc78a47685b74f8a30739b41df365ef90535d54;p=oweals%2Fubox.git kmodloader: don't store aliases info in struct module This also fixes FS#544 as the possible address alignment issue should now disappear function old new delta alloc_module 398 245 -153 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-153) Total: -153 bytes Signed-off-by: Yousong Zhou --- diff --git a/kmodloader.c b/kmodloader.c index ac14bac..892ddd8 100644 --- a/kmodloader.c +++ b/kmodloader.c @@ -48,8 +48,6 @@ struct module { char *name; char *depends; char *opts; - char **aliases; - int naliases; int size; int usage; @@ -250,16 +248,11 @@ alloc_module(const char *name, const char * const *aliases, int naliases, const { struct module *m; char *_name, *_dep; - char **_aliases; - int i, len_aliases; + int i; - len_aliases = naliases * sizeof(aliases[0]); - for (i = 0; i < naliases; i++) - len_aliases += strlen(aliases[i]) + 1; m = calloc_a(sizeof(*m), &_name, strlen(name) + 1, - &_dep, depends ? strlen(depends) + 2 : 0, - &_aliases, len_aliases); + &_dep, depends ? strlen(depends) + 2 : 0); if (!m) return NULL; @@ -275,28 +268,11 @@ alloc_module(const char *name, const char * const *aliases, int naliases, const } } m->size = size; - m->naliases = naliases; - if (naliases == 0) - m->aliases = NULL; - else { - char *ptr = (char *)_aliases + naliases * sizeof(_aliases[0]); - int len; - - i = 0; - do { - len = strlen(aliases[i]) + 1; - memcpy(ptr, aliases[i], len); - _aliases[i] = ptr; - ptr += len; - i++; - } while (i < naliases); - m->aliases = _aliases; - } m->refcnt = 0; alloc_module_node(m->name, m, false); - for (i = 0; i < m->naliases; i++) - alloc_module_node(m->aliases[i], m, true); + for (i = 0; i < naliases; i++) + alloc_module_node(aliases[i], m, true); return m; }