diff options
| author | Matthew Parlane <parlane@gmail.com> | 2014-02-08 14:23:34 +1300 |
|---|---|---|
| committer | Matthew Parlane <parlane@gmail.com> | 2014-02-08 14:32:48 +1300 |
| commit | ebff7974c3373cb96516cac0aa944e48b54e1d6b (patch) | |
| tree | 32276aa7db6fbff03c6b4692dd32d95844c7b173 /Source/Core/Common/MemArena.cpp | |
| parent | 64e01ec763d21915e7166e625f8a3e85b46fbcbb (diff) | |
Some tidy up of sprintf to StringFromFormat
Diffstat (limited to 'Source/Core/Common/MemArena.cpp')
| -rw-r--r-- | Source/Core/Common/MemArena.cpp | 12 |
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 |
