[Initng-svn] r4031 - initng/trunk/plugins/iparser
svn at initng.thinktux.net
svn at initng.thinktux.net
Sun May 7 12:07:41 CEST 2006
Author: jimmy
Date: Sun May 7 12:07:40 2006
New Revision: 4031
Modified:
initng/trunk/plugins/iparser/initng_i_parser.c
Log:
Optimize, A little more code, prevents an malloc moast of the time.
Modified: initng/trunk/plugins/iparser/initng_i_parser.c
==============================================================================
--- initng/trunk/plugins/iparser/initng_i_parser.c (original)
+++ initng/trunk/plugins/iparser/initng_i_parser.c Sun May 7 12:07:40 2006
@@ -161,7 +161,11 @@
strcat(filetoparse, service_strip);
strcat(filetoparse, INITNG_EXT);
if ((got_serv = parse_file(filetoparse, service_to_find)))
+ {
+ if(path != service_to_find)
+ free(path);
return (got_serv);
+ }
/* 2. try /etc/initng/daemon/bluetooth/serial/daemon/default.i */
strcpy(filetoparse, INITNG_ROOT "/");
@@ -169,15 +173,22 @@
strcat(filetoparse, "/default");
strcat(filetoparse, INITNG_EXT);
if ((got_serv = parse_file(filetoparse, service_to_find)))
+ {
+ if(path != service_to_find)
+ free(path);
return (got_serv);
-
+ }
/* 3, try /etc/initng/daemon/bluetooth/serial/daemon.i */
strcpy(filetoparse, INITNG_ROOT "/");
strcat(filetoparse, path);
strcat(filetoparse, INITNG_EXT);
if ((got_serv = parse_file(filetoparse, service_to_find)))
+ {
+ if(path != service_to_find)
+ free(path);
return (got_serv);
-
+ }
+
if ((path_strip = strrchr(path, '/')))
path_strip++;
else
@@ -192,9 +203,18 @@
strcat(filetoparse, path_strip);
strcat(filetoparse, INITNG_EXT);
if ((got_serv = parse_file(filetoparse, service_to_find)))
+ {
+ if(path != service_to_find)
+ free(path);
return (got_serv);
+ }
}
+ /* Now we make a copy of path that we can modify */
+ path=i_strdup(service_to_find);
+ if(!path)
+ return(NULL);
+
/* Cut path on last '/' */
char *p = NULL;
@@ -217,7 +237,6 @@
static service_cache_h *initng_i_parser(const char *service_to_find)
{
service_cache_h *got_serv = NULL;
- char *path = NULL;
assert(service_to_find);
D_("Parsing for %s\n", service_to_find);
@@ -247,19 +266,11 @@
* and service "udevd"
*/
- path = i_strdup(service_to_find);
- if (!path)
- return (NULL);
-
- got_serv = test_parse(path, service_to_find);
+ got_serv = test_parse((char *) service_to_find, service_to_find);
if (got_serv)
- {
- free(path);
return (got_serv);
- }
D_("Was not able to parse: %s\n", service_to_find);
- free(path);
return (NULL);
}
More information about the Initng-svn
mailing list