summaryrefslogtreecommitdiff
path: root/Source/Core/Common/MemArena.cpp
diff options
context:
space:
mode:
authorMatthew Parlane <parlane@gmail.com>2014-02-08 14:23:34 +1300
committerMatthew Parlane <parlane@gmail.com>2014-02-10 17:25:18 +1300
commit32bfcc034f41276f0fad036dece8a8f632913dff (patch)
tree33955e265cab4ece64efbbcc475896e8e8d280b6 /Source/Core/Common/MemArena.cpp
parent8d25e12085b8e3785a9843a8ffb5545eeb109107 (diff)
Some tidy up of sprintf to StringFromFormat
Includes a small fix to SetupWiiMemory
Diffstat (limited to 'Source/Core/Common/MemArena.cpp')
-rw-r--r--Source/Core/Common/MemArena.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/Source/Core/Common/MemArena.cpp b/Source/Core/Common/MemArena.cpp
index e7f3911e91..699005dd52 100644
--- a/Source/Core/Common/MemArena.cpp
+++ b/Source/Core/Common/MemArena.cpp
@@ -6,6 +6,7 @@
#include "MemoryUtil.h"
#include "MemArena.h"
+#include "StringUtil.h"
#ifdef _WIN32
#include <windows.h>
@@ -57,20 +58,21 @@ void MemArena::GrabLowMemSpace(size_t size)
return;
}
#else
- char fn[64];
for (int i = 0; i < 10000; i++)
{
- sprintf(fn, "dolphinmem.%d", i);
- fd = shm_open(fn, O_RDWR | O_CREAT | O_EXCL, 0600);
+ std::string file_name = StringFromFormat("dolphinmem.%d", i);
+ fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600);
if (fd != -1)
+ {
+ shm_unlink(file_name.c_str());
break;
- if (errno != EEXIST)
+ }
+ else 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