summaryrefslogtreecommitdiff
path: root/plugins/Utils/mir_scope.h
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-05-18 22:10:43 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-05-18 22:10:43 +0000
commit725f68b6808a8a30778f58223fac75386f082785 (patch)
treeccba410760749d45139e5e78fd5e08f416ade1a0 /plugins/Utils/mir_scope.h
parentf920ef497f3299ae24fe783ce03bdd93b419f764 (diff)
plugins folders renaming
git-svn-id: http://svn.miranda-ng.org/main/trunk@61 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Utils/mir_scope.h')
-rw-r--r--plugins/Utils/mir_scope.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/plugins/Utils/mir_scope.h b/plugins/Utils/mir_scope.h
new file mode 100644
index 0000000000..2f54044d83
--- /dev/null
+++ b/plugins/Utils/mir_scope.h
@@ -0,0 +1,35 @@
+#ifndef __PTR_H__
+# define __PTR_H__
+
+
+template<class T>
+class scope
+{
+public:
+ scope(T t) : p(t) {}
+ ~scope() { mir_free(); }
+
+ void free()
+ {
+ if (p != NULL)
+ mir_free(p);
+ p = NULL;
+ }
+
+// T operator->() const { return p; }
+ operator T() const { return p; }
+
+ T detach()
+ {
+ T ret = p;
+ p = NULL;
+ return ret;
+ }
+
+private:
+ T p;
+};
+
+
+
+#endif // __PTR_H__