Remove the source files which got transferred to libpbd
[ardour.git] / libs / ardour / linux_vst_support.cc
index 9d36905f489465614df4ab28a7aecb0341577f40..bd1ed0d27e01946e4da747d6ef10f48f136450a2 100644 (file)
@@ -112,7 +112,7 @@ vstfx_new ()
 void* vstfx_load_vst_library(const char* path)
 {
        void* dll;
-       char* full_path;
+       char* full_path = NULL;
        char* envdup;
        char* lxvst_path;
        size_t len1;
@@ -152,14 +152,15 @@ void* vstfx_load_vst_library(const char* path)
        len2 = strlen(path);
 
        /*Try all the possibilities in the path - deliminated by : */
-
-       lxvst_path = strtok (envdup, ":");
+       char *saveptr;
+       lxvst_path = strtok_r (envdup, ":", &saveptr);
        
        while (lxvst_path != 0)
        {
                vstfx_error ("\"%s\"", lxvst_path);
                len1 = strlen(lxvst_path);
                
+               if (full_path) free(full_path);
                full_path = (char*)malloc(len1 + 1 + len2 + 1);
                memcpy(full_path, lxvst_path, len1);
                full_path[len1] = '/';
@@ -176,11 +177,11 @@ void* vstfx_load_vst_library(const char* path)
        
                /*Try again*/
 
-               lxvst_path = strtok (0, ":");
+               lxvst_path = strtok_r (0, ":", &saveptr);
        }
 
        /*Free the path*/
-
+       if (full_path) free(full_path);
        free(envdup);
 
        return dll;
@@ -209,8 +210,6 @@ vstfx_load (const char *path)
                buf = (char *)malloc(strlen(path) + 4); //The .so and a terminating zero
 
                sprintf (buf, "%s.so", path);
-               
-               fhandle->nameptr = strdup (path);
 
        }
        else
@@ -218,8 +217,6 @@ vstfx_load (const char *path)
                /*We already have .so appened to the filename*/
                
                buf = strdup(path);
-               
-               fhandle->nameptr = strdup (path);
        }
 
        /* get a name for the plugin based on the path: ye old VST problem where
@@ -227,7 +224,7 @@ vstfx_load (const char *path)
           which we don't want to do at this point
        */
        
-       fhandle->name = strdup (PBD::basename_nosuffix (fhandle->nameptr).c_str());
+       fhandle->name = strdup (PBD::basename_nosuffix (path).c_str());
 
        /*call load_vstfx_library to actually load the .so into memory*/
 
@@ -289,9 +286,8 @@ vstfx_unload (VSTHandle* fhandle)
                fhandle->dll = 0;
        }
 
-       if (fhandle->nameptr)
+       if (fhandle->name)
        {
-               free (fhandle->nameptr);
                free (fhandle->name);
        }
        
@@ -310,8 +306,9 @@ vstfx_instantiate (VSTHandle* fhandle, audioMasterCallback amc, void* userptr)
 
        if(fhandle == 0)
        {
-           vstfx_error( "** ERROR ** VSTFX : The handle was 0\n" );
-           return 0;
+               vstfx_error( "** ERROR ** VSTFX : The handle was 0\n" );
+               free (vstfx);
+               return 0;
        }
 
        if ((vstfx->plugin = fhandle->main_entry (amc)) == 0)