fix crash at session close/exit if a midi-control-surface is used
[ardour.git] / libs / pbd / mountpoint.cc
index 045e8152827a47a9cd9b50947615f1046f294906..65f011c745efa0de2f005366d3de4214985073ee 100644 (file)
@@ -17,7 +17,7 @@
 
     $Id$
 */
-
+#ifndef  COMPILER_MSVC
 #include <cstdio>
 #include <cstring>
 #include <string>
@@ -94,6 +94,14 @@ mountpoint (string path)
        return best;
 }
 
+#elif defined(PLATFORM_WINDOWS)
+
+string
+mountpoint (string path)
+{
+       // TODO ... if needed
+}
+
 #else // !HAVE_GETMNTENT
 
 #include <sys/param.h>
@@ -110,8 +118,13 @@ mountpoint (string path)
        const char *cpath = path.c_str();
        char best[PATH_MAX+1];
        
+       /* From the manpage, under "BUGS" : "The memory allocated by getmntinfo() cannot be free(3)'d by the 
+          application."
+          
+          Thus: we do NOT try to free memory allocated by getmntinfo()
+       */
+
        if ((count = getmntinfo(&mntbufp, MNT_NOWAIT)) == 0) {
-               free(mntbufp);
                return "\0";
        }
 
@@ -135,7 +148,6 @@ mountpoint (string path)
 
                if (cpath[matchlen] == '\0') {
                        snprintf(best, sizeof(best), "%s", mntbufp[i].f_mntonname);
-                       free(mntbufp);
                        return best;
 
                } else {
@@ -146,12 +158,6 @@ mountpoint (string path)
                        }
                }
        }
-
-       /* From the manpage, under "BUGS" : "The memory allocated by getmntinfo() cannot be free(3)'d by the 
-          application."
-
-          free(mntbufp);
-       */
        
        return best;
 }
@@ -166,3 +172,7 @@ main (int argc, char *argv[])
 }
 
 #endif // TEST_MOUNTPOINT
+
+#else  // COMPILER_MSVC
+       const char* pbd_mountpoint = "pbd/msvc/mountpoint.cc takes precedence over this file";
+#endif // COMPILER_MSVC