Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CRYPTO_AUTO_CBB_H_ | |
| 6 #define CRYPTO_AUTO_CBB_H_ | |
| 7 | |
| 8 #include <openssl/bytestring.h> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 | |
| 12 namespace crypto { | |
| 13 | |
| 14 // AutoCBB is a wrapper over OpenSSL's CBB type that automatically releases | |
| 15 // resources when going out of scope. | |
| 16 class AutoCBB { | |
|
davidben
2016/02/26 21:51:34
I still very strongly think this is a bad name and
| |
| 17 public: | |
| 18 AutoCBB() { CBB_zero(&cbb_); } | |
| 19 ~AutoCBB() { CBB_cleanup(&cbb_); } | |
| 20 | |
| 21 CBB* get() { return &cbb_; } | |
| 22 | |
| 23 void Reset() { | |
| 24 CBB_cleanup(&cbb_); | |
| 25 CBB_zero(&cbb_); | |
| 26 } | |
| 27 | |
| 28 private: | |
| 29 CBB cbb_; | |
| 30 DISALLOW_COPY_AND_ASSIGN(AutoCBB); | |
| 31 }; | |
| 32 | |
| 33 } // namespace crypto | |
| 34 | |
| 35 #endif // CRYPTO_AUTO_CBB_H_ | |
| OLD | NEW |