X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fpbd%2Fmountpoint.cc;h=65f011c745efa0de2f005366d3de4214985073ee;hb=bb8cb93789b2eec65e4d82e5ceb64054673cbc4f;hp=a4063a0e4081d02fc1b84074d82b77afd26ede9b;hpb=16d97766465ba87cd69412836d65e68395e84943;p=ardour.git diff --git a/libs/pbd/mountpoint.cc b/libs/pbd/mountpoint.cc index a4063a0e40..65f011c745 100644 --- a/libs/pbd/mountpoint.cc +++ b/libs/pbd/mountpoint.cc @@ -17,22 +17,22 @@ $Id$ */ - +#ifndef COMPILER_MSVC #include #include #include #include #include -#include +#include "pbd/mountpoint.h" using std::string; -#ifdef HAVE_WAFCONFIG_H -#include "wafconfig.h" +#ifdef WAF_BUILD +#include "libpbd-config.h" #endif -#if HAVE_GETMNTENT +#ifdef HAVE_GETMNTENT #include struct mntent_sorter { @@ -94,6 +94,14 @@ mountpoint (string path) return best; } +#elif defined(PLATFORM_WINDOWS) + +string +mountpoint (string path) +{ + // TODO ... if needed +} + #else // !HAVE_GETMNTENT #include @@ -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,8 +158,6 @@ mountpoint (string path) } } } - - free(mntbufp); return best; } @@ -162,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