]> jfr.im git - solanum.git/commitdiff
Simplify module path list, removing strcpy use.
authorJilles Tjoelker <redacted>
Sun, 23 Feb 2014 22:47:27 +0000 (23:47 +0100)
committerJilles Tjoelker <redacted>
Sun, 23 Feb 2014 22:47:27 +0000 (23:47 +0100)
include/modules.h
src/modules.c

index b0a92dd33c52bacae91f6d5a6cc5a1ff05774c8c..66356234e4475dc17374c2c31b9fd756124f9a3a 100644 (file)
@@ -52,11 +52,6 @@ struct module
        void * mapi_header; /* actually struct mapi_mheader_av<mapi_version>    */
 };
 
-struct module_path
-{
-       char path[PATH_MAX];
-};
-
 #define MAPI_MAGIC_HDR 0x4D410000
 
 #define MAPI_V1                (MAPI_MAGIC_HDR | 0x1)
index 692c14fa4ab4582eeb5304dc60d604bc2e8446b0..00797e9515b69c25c775c37b5554f09b3294ac1a 100644 (file)
@@ -130,17 +130,17 @@ modules_init(void)
  * output      - none
  * side effects - returns a module path from path
  */
-static struct module_path *
+static char *
 mod_find_path(const char *path)
 {
        rb_dlink_node *ptr;
-       struct module_path *mpath;
+       char *mpath;
 
        RB_DLINK_FOREACH(ptr, mod_paths.head)
        {
                mpath = ptr->data;
 
-               if(!strcmp(path, mpath->path))
+               if(!strcmp(path, mpath))
                        return mpath;
        }
 
@@ -156,14 +156,12 @@ mod_find_path(const char *path)
 void
 mod_add_path(const char *path)
 {
-       struct module_path *pathst;
+       char *pathst;
 
        if(mod_find_path(path))
                return;
 
-       pathst = rb_malloc(sizeof(struct module_path));
-
-       strcpy(pathst->path, path);
+       pathst = rb_strdup(path);
        rb_dlinkAddAlloc(pathst, &mod_paths);
 }
 
@@ -288,7 +286,7 @@ load_one_module(const char *path, int coremodule)
 {
        char modpath[PATH_MAX];
        rb_dlink_node *pathst;
-       struct module_path *mpath;
+       const char *mpath;
 
        struct stat statbuf;
 
@@ -299,7 +297,7 @@ load_one_module(const char *path, int coremodule)
        {
                mpath = pathst->data;
 
-               rb_snprintf(modpath, sizeof(modpath), "%s/%s", mpath->path, path);
+               rb_snprintf(modpath, sizeof(modpath), "%s/%s", mpath, path);
                if((strstr(modpath, "../") == NULL) && (strstr(modpath, "/..") == NULL))
                {
                        if(stat(modpath, &statbuf) == 0)