Add macOS to some Linux/Android-only-isms

This commit is contained in:
Connor McLaughlin
2020-02-14 22:58:10 +09:00
parent 5aba89091e
commit 23c8a5588d
5 changed files with 7 additions and 13 deletions

View File

@ -1389,10 +1389,10 @@ std::string GetProgramPath()
#elif defined(__APPLE__)
int curSize = PATH_MAX;
char* buffer = static_cast<char*>(std::realloc(nullptr, curSize + 1));
char* buffer = static_cast<char*>(std::realloc(nullptr, curSize));
for (;;)
{
uint32 nChars = PATH_MAX - 1;
uint32 nChars = curSize - 1;
int res = _NSGetExecutablePath(buffer, &nChars);
if (res == 0)
{
@ -1410,12 +1410,6 @@ std::string GetProgramPath()
return ret;
}
if (curSize >= 1048576)
{
std::free(buffer);
return {};
}
curSize *= 2;
buffer = static_cast<char*>(std::realloc(buffer, curSize + 1));
}