summaryrefslogtreecommitdiffstats
path: root/auto_free.h
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2008-07-04 17:11:29 -0400
committerFrank Ch. Eigler <fche@elastic.org>2008-07-04 17:11:29 -0400
commit53f7dd30e87fa480c5d43ce2a1312ce27a4372c9 (patch)
tree4f1c64048d43c50c11877a66d3f7f918e43a0f7b /auto_free.h
parent1b94bf6d310cf41041d0a6c24be85a892d443708 (diff)
parent422b0781177e0755df5542e1c70e809e6f3cfe89 (diff)
downloadsystemtap-steved-53f7dd30e87fa480c5d43ce2a1312ce27a4372c9.tar.gz
systemtap-steved-53f7dd30e87fa480c5d43ce2a1312ce27a4372c9.tar.xz
systemtap-steved-53f7dd30e87fa480c5d43ce2a1312ce27a4372c9.zip
Merge commit 'origin/master' into pr6429-comp-unwindsyms
* commit 'origin/master': ubuntu (2.6.24-16-server) kernel compatibility fix client/server take 2. See bz6565. Add functioncallcount.meta and functioncallcount.stp. Add para-callgraph.stp and para-callgraph.meta. Fixed __stp_get_mm_path() error return code. diagnostics improvement: print arch/mach at top if -vv Make _vfs.generic_commit_write only for kernel<=2.6.25 Handles "mortally wounded" threads correctly when detaching. further clarify that elfutils need not be absolutely freshest, nor rebuilt every time point out releases/ directory; clarify optionality of elfutils bundling Add auto_free_ref to auto_free stuff; bug 6694
Diffstat (limited to 'auto_free.h')
-rw-r--r--auto_free.h28
1 files changed, 23 insertions, 5 deletions
diff --git a/auto_free.h b/auto_free.h
index b13e7371..58290821 100644
--- a/auto_free.h
+++ b/auto_free.h
@@ -27,14 +27,32 @@ public:
}
private:
// No copying allowed.
- auto_free(const auto_free& af)
+ auto_free(const auto_free& af);
+ // No assignment either
+ auto_free& operator=(const auto_free& rhs);
+ void* _ptr;
+};
+
+// Use this to free a pointer whose value may change after the initial
+// allocation e.g., be realloced.
+template <typename T>
+class auto_free_ref
+{
+public:
+ typedef T pointer_type;
+ auto_free_ref(pointer_type& ptr) : _ptr(ptr)
{
}
- // No assignment either
- auto_free& operator=(const auto_free& rhs)
+ ~auto_free_ref()
{
- return *this;
+ if (_ptr)
+ std::free(_ptr);
}
- void* _ptr;
+private:
+ // No copying allowed.
+ auto_free_ref(const auto_free_ref& af);
+ // No assignment either
+ auto_free_ref& operator=(const auto_free_ref& rhs);
+ pointer_type& _ptr;
};
#endif