summaryrefslogtreecommitdiff
path: root/plugins/Utils/mir_scope.h
blob: 2f54044d832ee04d325adf9d87172bde264e4fc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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__