FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 11-18-2009, 02:11 AM
David Cantrell
 
Default Use glib string parsing functions in driverselect.c.

---
loader/driverselect.c | 40 +++++++++-------------------------------
1 files changed, 9 insertions(+), 31 deletions(-)

diff --git a/loader/driverselect.c b/loader/driverselect.c
index 28f5ffd..3db9dc4 100644
--- a/loader/driverselect.c
+++ b/loader/driverselect.c
@@ -49,7 +49,7 @@ static int sortDrivers(const void * a, const void * b) {
one->modInfo->moduleList[two->index].description);
}

-static int getManualModuleArgs(struct moduleInfo * mod, char *** moduleArgs) {
+static int getManualModuleArgs(struct moduleInfo * mod, gchar *** moduleArgs) {
newtGrid grid, buttons;
newtComponent text, f, ok, back, entry;
struct newtExitStruct es;
@@ -113,31 +113,7 @@ static int getManualModuleArgs(struct moduleInfo * mod, char *** moduleArgs) {
logMessage(INFO, "specified args of %s for %s", argsEntry, mod->moduleName);

if (strlen(argsEntry) > 0) {
- int numAlloced = 5;
- char * start;
- char * end;
-
- i = 0;
-
- *moduleArgs = malloc((numAlloced + 1) * sizeof(*moduleArgs));
- start = argsEntry;
- while (start && *start) {
- end = start;
- while (!isspace(*end) && *end) end++;
- *end = '';
- (*moduleArgs)[i++] = strdup(start);
- start = end + 1;
- *end = ' ';
- start = strchr(end, ' ');
- if (start) start++;
-
- if (i >= numAlloced) {
- numAlloced += 5;
- *moduleArgs = realloc(*moduleArgs,
- sizeof(*moduleArgs) * (numAlloced + 1));
- }
- }
- (*moduleArgs)[i] = NULL;
+ *moduleArgs = g_strsplit(argsEntry, " ", 0);
}

newtFormDestroy(f);
@@ -151,7 +127,7 @@ int chooseManualDriver(int class, struct loaderData_s *loaderData) {
enum driverMajor type;
struct sortModuleList * sortedOrder;
char giveArgs = ' ';
- char ** moduleArgs = NULL;
+ gchar **moduleArgs = NULL;
moduleInfoSet modInfo = loaderData->modInfo;

newtComponent text, f, ok, back, argcheckbox, listbox;
@@ -246,8 +222,8 @@ int chooseManualDriver(int class, struct loaderData_s *loaderData) {
done = -2;
} else {
if (giveArgs != ' ') {
- i = getManualModuleArgs(&(modInfo->moduleList[num]),
- &moduleArgs);
+ i = getManualModuleArgs(&(modInfo->moduleList[num]),
+ &moduleArgs);
if (i == LOADER_BACK)
done = 0;
else
@@ -272,7 +248,9 @@ int chooseManualDriver(int class, struct loaderData_s *loaderData) {
mlLoadModule(modInfo->moduleList[num].moduleName, moduleArgs);
free(sortedOrder);

+ if (moduleArgs) {
+ g_strfreev(moduleArgs);
+ }
+
return LOADER_OK;
}
-
-
--
1.6.5.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 11-18-2009, 09:51 AM
Hans de Goede
 
Default Use glib string parsing functions in driverselect.c.

Looks ok, ack.


On 11/18/2009 04:11 AM, David Cantrell wrote:

---
loader/driverselect.c | 40 +++++++++-------------------------------
1 files changed, 9 insertions(+), 31 deletions(-)

diff --git a/loader/driverselect.c b/loader/driverselect.c
index 28f5ffd..3db9dc4 100644
--- a/loader/driverselect.c
+++ b/loader/driverselect.c
@@ -49,7 +49,7 @@ static int sortDrivers(const void * a, const void * b) {
one->modInfo->moduleList[two->index].description);
}

-static int getManualModuleArgs(struct moduleInfo * mod, char *** moduleArgs) {
+static int getManualModuleArgs(struct moduleInfo * mod, gchar *** moduleArgs) {
newtGrid grid, buttons;
newtComponent text, f, ok, back, entry;
struct newtExitStruct es;
@@ -113,31 +113,7 @@ static int getManualModuleArgs(struct moduleInfo * mod, char *** moduleArgs) {
logMessage(INFO, "specified args of %s for %s", argsEntry, mod->moduleName);

if (strlen(argsEntry)> 0) {
- int numAlloced = 5;
- char * start;
- char * end;
-
- i = 0;
-
- *moduleArgs = malloc((numAlloced + 1) * sizeof(*moduleArgs));
- start = argsEntry;
- while (start&& *start) {
- end = start;
- while (!isspace(*end)&& *end) end++;
- *end = '';
- (*moduleArgs)[i++] = strdup(start);
- start = end + 1;
- *end = ' ';
- start = strchr(end, ' ');
- if (start) start++;
-
- if (i>= numAlloced) {
- numAlloced += 5;
- *moduleArgs = realloc(*moduleArgs,
- sizeof(*moduleArgs) * (numAlloced + 1));
- }
- }
- (*moduleArgs)[i] = NULL;
+ *moduleArgs = g_strsplit(argsEntry, " ", 0);
}

newtFormDestroy(f);
@@ -151,7 +127,7 @@ int chooseManualDriver(int class, struct loaderData_s *loaderData) {
enum driverMajor type;
struct sortModuleList * sortedOrder;
char giveArgs = ' ';
- char ** moduleArgs = NULL;
+ gchar **moduleArgs = NULL;
moduleInfoSet modInfo = loaderData->modInfo;

newtComponent text, f, ok, back, argcheckbox, listbox;
@@ -246,8 +222,8 @@ int chooseManualDriver(int class, struct loaderData_s *loaderData) {
done = -2;
} else {
if (giveArgs != ' ') {
- i = getManualModuleArgs(&(modInfo->moduleList[num]),
-&moduleArgs);
+ i = getManualModuleArgs(&(modInfo->moduleList[num]),
+&moduleArgs);
if (i == LOADER_BACK)
done = 0;
else
@@ -272,7 +248,9 @@ int chooseManualDriver(int class, struct loaderData_s *loaderData) {
mlLoadModule(modInfo->moduleList[num].moduleName, moduleArgs);
free(sortedOrder);

+ if (moduleArgs) {
+ g_strfreev(moduleArgs);
+ }
+
return LOADER_OK;
}
-
-


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 01:33 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org