summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/clover/util
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2014-02-18 17:13:39 +0100
committerFrancisco Jerez <[email protected]>2014-02-21 12:51:22 +0100
commita0d99937a0b4e778cc0b2e93886c814dd8819f6d (patch)
tree7c54830c49479a6732c2e1963d16792abef98939 /src/gallium/state_trackers/clover/util
parentc4578d2277155c50c8680849763850cddb8e8ec2 (diff)
clover: Replace the transfer(new ...) idiom with a safer create(...) helper function.
Tested-by: Tom Stellard <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/clover/util')
-rw-r--r--src/gallium/state_trackers/clover/util/pointer.hpp26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/gallium/state_trackers/clover/util/pointer.hpp b/src/gallium/state_trackers/clover/util/pointer.hpp
index 98823aa7860..59c6e6e9f64 100644
--- a/src/gallium/state_trackers/clover/util/pointer.hpp
+++ b/src/gallium/state_trackers/clover/util/pointer.hpp
@@ -122,18 +122,6 @@ namespace clover {
};
///
- /// Transfer the caller's ownership of a reference-counted object
- /// to a clover::intrusive_ptr smart pointer.
- ///
- template<typename T>
- inline intrusive_ptr<T>
- transfer(T *p) {
- intrusive_ptr<T> ref { p };
- p->release();
- return ref;
- }
-
- ///
/// Intrusive smart reference for objects that implement the
/// clover::ref_counter interface.
///
@@ -188,14 +176,14 @@ namespace clover {
};
///
- /// Transfer the caller's ownership of a reference-counted object
- /// to a clover::intrusive_ref smart reference.
+ /// Initialize a clover::intrusive_ref from a newly created object
+ /// using the specified constructor arguments.
///
- template<typename T>
- inline intrusive_ref<T>
- transfer(T &o) {
- intrusive_ref<T> ref { o };
- o.release();
+ template<typename T, typename... As>
+ intrusive_ref<T>
+ create(As &&... as) {
+ intrusive_ref<T> ref { *new T(std::forward<As>(as)...) };
+ ref().release();
return ref;
}