Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(936)

Unified Diff: crypto/auto_cbb.h

Issue 1739403002: Cut down on usage of deprecated APIs in //crypto. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grumble grumble string vector char uint8_t grumble Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crypto/BUILD.gn ('k') | crypto/crypto.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/auto_cbb.h
diff --git a/crypto/auto_cbb.h b/crypto/auto_cbb.h
new file mode 100644
index 0000000000000000000000000000000000000000..5206a214f97cc1be8ddb9622ba27648926cba350
--- /dev/null
+++ b/crypto/auto_cbb.h
@@ -0,0 +1,35 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CRYPTO_AUTO_CBB_H_
+#define CRYPTO_AUTO_CBB_H_
+
+#include <openssl/bytestring.h>
+
+#include "base/macros.h"
+
+namespace crypto {
+
+// AutoCBB is a wrapper over OpenSSL's CBB type that automatically releases
+// resources when going out of scope.
+class AutoCBB {
+ public:
+ AutoCBB() { CBB_zero(&cbb_); }
+ ~AutoCBB() { CBB_cleanup(&cbb_); }
+
+ CBB* get() { return &cbb_; }
+
+ void Reset() {
+ CBB_cleanup(&cbb_);
+ CBB_zero(&cbb_);
+ }
+
+ private:
+ CBB cbb_;
+ DISALLOW_COPY_AND_ASSIGN(AutoCBB);
+};
+
+} // namespace crypto
+
+#endif // CRYPTO_AUTO_CBB_H_
« no previous file with comments | « crypto/BUILD.gn ('k') | crypto/crypto.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698