acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
LocalMemory.h
1//*****************************************************************************
2//
3// Class: LocalMemory
4// Author: Kenny Kerr
5// Date created: 10 April 2004
6// Description: Provides automatic cleanup of local memory objects.
7//
8//*****************************************************************************
9
10#pragma once
11
12namespace Kerr
13{
14 template <typename T>
15 class LocalMemory
16 {
17 public:
18
19 explicit LocalMemory(T* pBuffer) :
20 m_pBuffer(pBuffer)
21 {
22 // Do nothing
23 }
24
25 virtual ~LocalMemory()
26 {
27 Free();
28 }
29
30 void Free()
31 {
32 if (0 != m_pBuffer)
33 {
34 ::LocalFree(m_pBuffer);
35 m_pBuffer = 0;
36 }
37 }
38
39 T* m_pBuffer;
40 };
41}