summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authordcheng <dcheng@chromium.org>2014-10-14 15:42:04 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-14 22:42:51 +0000
commit9961abd411eab6ec1cf9421078dfdaa001a7e2b5 (patch)
tree523c6acca5ec4a678fc920b53b82f4a4b41d06ec /crypto
parent42f3be833bb3854c6143574f92a1ec6f973508b5 (diff)
downloadchromium_src-9961abd411eab6ec1cf9421078dfdaa001a7e2b5.zip
chromium_src-9961abd411eab6ec1cf9421078dfdaa001a7e2b5.tar.gz
chromium_src-9961abd411eab6ec1cf9421078dfdaa001a7e2b5.tar.bz2
Allow custom deleters to opt out of self reset checks for scoped_ptr.
The self-reset check makes sense for the default deleters, because it would otherwise leave a dangling pointer stored in the scoped_ptr. However, a custom deleter might actually decrement a reference count under the hood. This self-reset check can make assignment operators implementation a lot uglier. One example is net's KeyPair: because there might be a self-assignment, the original code needed to proxy the incoming scoped_ptrs via a stack temporary before moving them into their final location. BUG=418347 Review URL: https://codereview.chromium.org/610533003 Cr-Commit-Position: refs/heads/master@{#299571}
Diffstat (limited to 'crypto')
-rw-r--r--crypto/scoped_nss_types.h2
-rw-r--r--crypto/scoped_openssl_types.h1
2 files changed, 3 insertions, 0 deletions
diff --git a/crypto/scoped_nss_types.h b/crypto/scoped_nss_types.h
index 8e96e8d..fdfb83c 100644
--- a/crypto/scoped_nss_types.h
+++ b/crypto/scoped_nss_types.h
@@ -16,6 +16,7 @@ namespace crypto {
template <typename Type, void (*Destroyer)(Type*)>
struct NSSDestroyer {
+ typedef void AllowSelfReset;
void operator()(Type* ptr) const {
Destroyer(ptr);
}
@@ -23,6 +24,7 @@ struct NSSDestroyer {
template <typename Type, void (*Destroyer)(Type*, PRBool), PRBool freeit>
struct NSSDestroyer1 {
+ typedef void AllowSelfReset;
void operator()(Type* ptr) const {
Destroyer(ptr, freeit);
}
diff --git a/crypto/scoped_openssl_types.h b/crypto/scoped_openssl_types.h
index d0428fb..cc056e4 100644
--- a/crypto/scoped_openssl_types.h
+++ b/crypto/scoped_openssl_types.h
@@ -22,6 +22,7 @@ namespace crypto {
// base::internal::RunnableAdapter<>, but that's far too heavy weight.
template <typename Type, void (*Destroyer)(Type*)>
struct OpenSSLDestroyer {
+ typedef void AllowSelfReset;
void operator()(Type* ptr) const { Destroyer(ptr); }
};