Revert "Merge pull request #49 from Parlane/sprintf_tidy"

Change broke the build on Debian stable.

This reverts commit 28755439b3, reversing
changes made to 64e01ec763.
This commit is contained in:
Pierre Bourdon
2014-02-09 16:12:59 +01:00
parent 9da6900595
commit e59f770ccb
13 changed files with 112 additions and 65 deletions

View File

@ -6,7 +6,6 @@
#include "MemoryUtil.h"
#include "MemArena.h"
#include "StringUtil.h"
#ifdef _WIN32
#include <windows.h>
@ -58,21 +57,20 @@ void MemArena::GrabLowMemSpace(size_t size)
return;
}
#else
char fn[64];
for (int i = 0; i < 10000; i++)
{
std::string file_name = StringFromFormat("dolphinmem.%d", i);
fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600);
sprintf(fn, "dolphinmem.%d", i);
fd = shm_open(fn, O_RDWR | O_CREAT | O_EXCL, 0600);
if (fd != -1)
{
shm_unlink(file_name.c_str());
break;
}
else if (errno != EEXIST)
if (errno != EEXIST)
{
ERROR_LOG(MEMMAP, "shm_open failed: %s", strerror(errno));
return;
}
}
shm_unlink(fn);
if (ftruncate(fd, size) < 0)
ERROR_LOG(MEMMAP, "Failed to allocate low memory space");
#endif