]> sourceware.org Git - systemtap.git/blob - auto_free.h
Merge commit 'origin/master' into pr6429-comp-unwindsyms
[systemtap.git] / auto_free.h
1 // -*- C++ -*-
2 // Copyright (C) 2008 Red Hat Inc.
3 //
4 // This file is part of systemtap, and is free software. You can
5 // redistribute it and/or modify it under the terms of the GNU General
6 // Public License (GPL); either version 2, or (at your option) any
7 // later version.
8
9 #ifndef AUTO_FREE_H
10 #define AUTO_FREE_H 1
11 #include <cstdlib>
12
13 // Very simple auto_ptr-like class for protecting storage allocated
14 // with free().
15 class auto_free
16 {
17 public:
18 auto_free(void* ptr) : _ptr(ptr) {}
19 ~auto_free()
20 {
21 if (_ptr)
22 std::free(_ptr);
23 }
24 void release()
25 {
26 _ptr = 0;
27 }
28 private:
29 // No copying allowed.
30 auto_free(const auto_free& af)
31 {
32 }
33 // No assignment either
34 auto_free& operator=(const auto_free& rhs)
35 {
36 return *this;
37 }
38 void* _ptr;
39 };
40 #endif
This page took 0.04163 seconds and 6 git commands to generate.