From 7bc325d90b89112495acd91ec5381eb48183c93b Mon Sep 17 00:00:00 2001 From: Palana Date: Mon, 16 Dec 2013 01:55:27 +0100 Subject: [PATCH] updated BPtr semantics to be more in line with stl smart pointers --- obs/obs-app.cpp | 4 ++-- obs/obs-wrappers.hpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/obs/obs-app.cpp b/obs/obs-app.cpp index fff15bcfd..25b480ee2 100644 --- a/obs/obs-app.cpp +++ b/obs/obs-app.cpp @@ -70,7 +70,7 @@ static bool do_mkdir(const char *path) static bool MakeUserDirs() { - BPtr homePath(os_get_home_path()); + BPtr homePath(os_get_home_path()); stringstream str; str << homePath << "/obs-studio"; @@ -82,7 +82,7 @@ static bool MakeUserDirs() bool OBSApp::InitGlobalConfig() { - BPtr homePath = os_get_home_path(); + BPtr homePath(os_get_home_path()); stringstream str; if (!homePath) { diff --git a/obs/obs-wrappers.hpp b/obs/obs-wrappers.hpp index 705e185be..9671f0051 100644 --- a/obs/obs-wrappers.hpp +++ b/obs/obs-wrappers.hpp @@ -27,20 +27,20 @@ /* RAII wrappers */ template class BPtr { - T ptr; + T *ptr; BPtr(BPtr const&) = delete; BPtr &operator=(BPtr const&) = delete; public: - inline BPtr(T p=nullptr) : ptr(p) {} + inline BPtr(T *p=nullptr) : ptr(p) {} inline BPtr(BPtr &&other) : ptr(other.ptr) {other.ptr = nullptr;} inline ~BPtr() {bfree(ptr);} - inline T operator=(T p) {bfree(ptr); ptr = p; return p;} - inline operator T() {return ptr;} - inline T *operator&() {bfree(ptr); ptr = NULL; return &ptr;} + inline T *operator=(T *p) {bfree(ptr); ptr = p; return p;} + inline operator T*() {return ptr;} + inline T **operator&() {bfree(ptr); ptr = nullptr; return &ptr;} inline bool operator!() {return ptr == NULL;} inline bool operator==(T p) {return ptr == p;} -- GitLab