mirror of
https://github.com/AuxXxilium/kmod.git
synced 2024-12-18 20:48:11 +07:00
Allow path_to_modname to operate locally withou alloc
This commit is contained in:
parent
49e61ca347
commit
9eaad1f63a
@ -46,7 +46,7 @@ struct kmod_module {
|
||||
const char *name;
|
||||
};
|
||||
|
||||
static char *path_to_modname(const char *path)
|
||||
static char *path_to_modname(const char *path, bool alloc)
|
||||
{
|
||||
char *modname;
|
||||
char *c;
|
||||
@ -55,7 +55,9 @@ static char *path_to_modname(const char *path)
|
||||
if (modname == NULL || modname[0] == '\0')
|
||||
return NULL;
|
||||
|
||||
modname = strdup(modname);
|
||||
if (alloc)
|
||||
modname = strdup(modname);
|
||||
|
||||
for (c = modname; *c != '\0' && *c != '.'; c++) {
|
||||
if (*c == '-')
|
||||
*c = '_';
|
||||
@ -68,7 +70,7 @@ static char *path_to_modname(const char *path)
|
||||
static const char *get_modname(struct kmod_module *mod)
|
||||
{
|
||||
if (mod->name == NULL)
|
||||
mod->name = path_to_modname(mod->path);
|
||||
mod->name = path_to_modname(mod->path, true);
|
||||
|
||||
return mod->name;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user