static struct module *new_module(const char *modname)
{
struct module *mod;
- char *p;
- mod = NOFAIL(malloc(sizeof(*mod)));
+ mod = NOFAIL(malloc(sizeof(*mod) + strlen(modname) + 1));
memset(mod, 0, sizeof(*mod));
- p = NOFAIL(strdup(modname));
-
- /* strip trailing .o */
- if (strends(p, ".o"))
- p[strlen(p) - 2] = '\0';
/* add to list */
- mod->name = p;
+ strcpy(mod->name, modname);
mod->is_vmlinux = is_vmlinux(modname);
mod->gpl_compatible = -1;
mod->next = modules;
if (!parse_elf(&info, modname))
return;
- mod = new_module(modname);
+ {
+ char *tmp;
+
+ /* strip trailing .o */
+ tmp = NOFAIL(strdup(modname));
+ tmp[strlen(tmp) - 2] = '\0';
+ mod = new_module(tmp);
+ free(tmp);
+ }
if (!mod->is_vmlinux) {
license = get_modinfo(&info, "license");
struct module {
struct module *next;
- const char *name;
int gpl_compatible;
struct symbol *unres;
int from_dump; /* 1 if module was loaded from *.symvers */
struct namespace_list *missing_namespaces;
// Actual imported namespaces
struct namespace_list *imported_namespaces;
+ char name[];
};
struct elf_info {