Backed out changeset e7acb4e12051 (bug 1893666) for causing xpcshell failures on...
[gecko.git] / security / nss / cpputil / scoped_ptrs_ssl.h
blob682ebab82924eaf11074ebcd754df72ca7ee177d
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef scoped_ptrs_ssl_h__
8 #define scoped_ptrs_ssl_h__
10 #include <memory>
11 #include "sslexp.h"
13 struct ScopedDeleteSSL {
14 void operator()(SSLAeadContext* ctx) { SSL_DestroyAead(ctx); }
15 void operator()(SSLMaskingContext* ctx) { SSL_DestroyMaskingContext(ctx); }
16 void operator()(SSLAntiReplayContext* ctx) {
17 SSL_ReleaseAntiReplayContext(ctx);
19 void operator()(SSLResumptionTokenInfo* token) {
20 SSL_DestroyResumptionTokenInfo(token);
24 template <class T>
25 struct ScopedMaybeDeleteSSL {
26 void operator()(T* ptr) {
27 if (ptr) {
28 ScopedDeleteSSL del;
29 del(ptr);
34 #define SCOPED(x) typedef std::unique_ptr<x, ScopedMaybeDeleteSSL<x> > Scoped##x
36 SCOPED(SSLAeadContext);
37 SCOPED(SSLAntiReplayContext);
38 SCOPED(SSLMaskingContext);
39 SCOPED(SSLResumptionTokenInfo);
41 #undef SCOPED
43 #endif // scoped_ptrs_ssl_h__