From 07bfe0abbb40d7131bbf12beb9eb829dbd8fb53b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 11 Sep 2015 23:04:19 -0400 Subject: [PATCH 1/3] general: Replace 0 literals with nullptr where applicable --- src/citra_qt/debugger/profiler.cpp | 2 +- src/citra_qt/debugger/profiler.h | 2 +- src/common/chunk_file.h | 4 ++-- src/common/memory_util.cpp | 8 ++++---- src/core/core_timing.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/citra_qt/debugger/profiler.cpp b/src/citra_qt/debugger/profiler.cpp index 043f20659..4f6ba0e1f 100644 --- a/src/citra_qt/debugger/profiler.cpp +++ b/src/citra_qt/debugger/profiler.cpp @@ -150,7 +150,7 @@ void ProfilerWidget::setProfilingInfoUpdateEnabled(bool enable) class MicroProfileWidget : public QWidget { public: - MicroProfileWidget(QWidget* parent = 0); + MicroProfileWidget(QWidget* parent = nullptr); protected: void paintEvent(QPaintEvent* ev) override; diff --git a/src/citra_qt/debugger/profiler.h b/src/citra_qt/debugger/profiler.h index 85c27a43e..036054740 100644 --- a/src/citra_qt/debugger/profiler.h +++ b/src/citra_qt/debugger/profiler.h @@ -53,7 +53,7 @@ class MicroProfileDialog : public QWidget { Q_OBJECT public: - MicroProfileDialog(QWidget* parent = 0); + MicroProfileDialog(QWidget* parent = nullptr); /// Returns a QAction that can be used to toggle visibility of this dialog. QAction* toggleViewAction(); diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h index 8be0b1109..1e1bcff31 100644 --- a/src/common/chunk_file.h +++ b/src/common/chunk_file.h @@ -575,10 +575,10 @@ public: } template* (*TNew)(), void (*TFree)(LinkedListItem*), void (*TDo)(PointerWrap&, T*)> - void DoLinkedList(LinkedListItem*& list_start, LinkedListItem** list_end=0) + void DoLinkedList(LinkedListItem*& list_start, LinkedListItem** list_end = nullptr) { LinkedListItem* list_cur = list_start; - LinkedListItem* prev = 0; + LinkedListItem* prev = nullptr; while (true) { diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index 5ef784224..b299b0f0f 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp @@ -28,9 +28,9 @@ void* AllocateExecutableMemory(size_t size, bool low) { #if defined(_WIN32) - void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + void* ptr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); #else - static char *map_hint = 0; + static char* map_hint = nullptr; #if defined(ARCHITECTURE_X64) && !defined(MAP_32BIT) // This OS has no flag to enforce allocation below the 4 GB boundary, // but if we hint that we want a low address it is very likely we will @@ -85,9 +85,9 @@ void* AllocateExecutableMemory(size_t size, bool low) void* AllocateMemoryPages(size_t size) { #ifdef _WIN32 - void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE); + void* ptr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); #else - void* ptr = mmap(0, size, PROT_READ | PROT_WRITE, + void* ptr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); if (ptr == MAP_FAILED) diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 20f2da0fe..56615502c 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -207,7 +207,7 @@ void ScheduleEvent_Threadsafe(s64 cycles_into_future, int event_type, u64 userda Event* new_event = GetNewTsEvent(); new_event->time = GetTicks() + cycles_into_future; new_event->type = event_type; - new_event->next = 0; + new_event->next = nullptr; new_event->userdata = userdata; if (!ts_first) ts_first = new_event; From 3972ac40eff770495cf1f29ed194c1351ed96135 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 11 Sep 2015 23:12:28 -0400 Subject: [PATCH 2/3] memory_util: Remove commented out printf statements --- src/common/memory_util.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index b299b0f0f..fc6696a36 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp @@ -49,9 +49,6 @@ void* AllocateExecutableMemory(size_t size, bool low) , -1, 0); #endif /* defined(_WIN32) */ - // printf("Mapped executable memory at %p (size %ld)\n", ptr, - // (unsigned long)size); - #ifdef _WIN32 if (ptr == nullptr) { @@ -69,7 +66,6 @@ void* AllocateExecutableMemory(size_t size, bool low) { map_hint += size; map_hint = (char*)round_page(map_hint); /* round up to the next page */ - // printf("Next map will (hopefully) be at %p\n", map_hint); } } #endif @@ -94,9 +90,6 @@ void* AllocateMemoryPages(size_t size) ptr = nullptr; #endif - // printf("Mapped memory at %p (size %ld)\n", ptr, - // (unsigned long)size); - if (ptr == nullptr) LOG_ERROR(Common_Memory, "Failed to allocate raw memory"); @@ -117,9 +110,6 @@ void* AllocateAlignedMemory(size_t size,size_t alignment) #endif #endif - // printf("Mapped memory at %p (size %ld)\n", ptr, - // (unsigned long)size); - if (ptr == nullptr) LOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); From 13683a6a1126f518f5325369ef5ea23ed4e487bc Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 11 Sep 2015 23:16:34 -0400 Subject: [PATCH 3/3] memory_util: Remove unnecessary assignment in FreeMemoryPages --- src/common/memory_util.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index fc6696a36..07c7f79c8 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp @@ -121,11 +121,8 @@ void FreeMemoryPages(void* ptr, size_t size) if (ptr) { #ifdef _WIN32 - if (!VirtualFree(ptr, 0, MEM_RELEASE)) LOG_ERROR(Common_Memory, "FreeMemoryPages failed!\n%s", GetLastErrorMsg()); - ptr = nullptr; // Is this our responsibility? - #else munmap(ptr, size); #endif