From ff839f5434f243d93addb4ad36977acc69ae07eb Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Mon, 11 Feb 2008 18:13:37 +0000 Subject: alloc the string in filename2modname --- mdk-stage1/modules.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'mdk-stage1/modules.c') diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c index b9cc3dd87..3b477f3c3 100644 --- a/mdk-stage1/modules.c +++ b/mdk-stage1/modules.c @@ -88,12 +88,19 @@ static char *kernel_module_extension(void) } -static void filename2modname(char * filename) { - while (filename && *filename) { - if (*filename == '-') - *filename = '_'; - filename++; +static char *filename2modname(char * filename) { + char *modname, *p; + + modname = strdup(filename); + + p = modname; + while (p && *p) { + if (*p == '-') + *p = '_'; + p++; } + + return modname; } static void find_modules_directory(void) @@ -135,8 +142,7 @@ static int load_modules_dependencies(void) /* sort of a good line */ modules_deps[line].filename = strdup(start); - modules_deps[line].modname = strdup(start); - filename2modname(modules_deps[line].modname); + modules_deps[line].modname = filename2modname(start); start = ptr; i = 0; @@ -195,8 +201,7 @@ static int load_modules_descriptions(void) *ptr = '\0'; ptr++; - modules_descr[line].modname = strdup(start); - filename2modname(modules_deps[line].modname); + modules_descr[line].modname = filename2modname(start); modules_descr[line].description = strndup(ptr, 50); line++; -- cgit v1.2.1