summaryrefslogtreecommitdiff
path: root/Plugins/utils/mir_scope.h
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins/utils/mir_scope.h')
-rw-r--r--Plugins/utils/mir_scope.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/Plugins/utils/mir_scope.h b/Plugins/utils/mir_scope.h
index a18bf55..31edde0 100644
--- a/Plugins/utils/mir_scope.h
+++ b/Plugins/utils/mir_scope.h
@@ -3,20 +3,22 @@
template<class T>
-class scope
+class mir_scope
{
public:
- scope(T t) : p(t) {}
- ~scope() { free(); }
+ mir_scope() : p(NULL) {}
+ mir_scope(T t) : p(t) {}
+ ~mir_scope() { release(); }
- void free()
+ void release()
{
if (p != NULL)
mir_free(p);
p = NULL;
}
-// T operator->() const { return p; }
+ T operator=(T t) { release(); p = t; return t; }
+ T operator->() const { return p; }
operator T() const { return p; }
T detach()