// Copyright (c) 2012 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_SCOPED_NSS_TYPES_H_ #define CRYPTO_SCOPED_NSS_TYPES_H_ #include #include #include #include #include "base/memory/scoped_ptr.h" namespace crypto { template struct NSSDestroyer { void operator()(Type* ptr) const { if (ptr) Destroyer(ptr); } }; template struct NSSDestroyer1 { void operator()(Type* ptr) const { if (ptr) Destroyer(ptr, freeit); } }; // Define some convenient scopers around NSS pointers. typedef scoped_ptr_malloc< PK11Context, NSSDestroyer1 > ScopedPK11Context; typedef scoped_ptr_malloc< PK11SlotInfo, NSSDestroyer > ScopedPK11Slot; typedef scoped_ptr_malloc< PK11SlotList, NSSDestroyer > ScopedPK11SlotList; typedef scoped_ptr_malloc< PK11SymKey, NSSDestroyer > ScopedPK11SymKey; typedef scoped_ptr_malloc< SECKEYPublicKey, NSSDestroyer > ScopedSECKEYPublicKey; typedef scoped_ptr_malloc< SECKEYPrivateKey, NSSDestroyer > ScopedSECKEYPrivateKey; typedef scoped_ptr_malloc< SECAlgorithmID, NSSDestroyer1 > ScopedSECAlgorithmID; typedef scoped_ptr_malloc< SECItem, NSSDestroyer1 > ScopedSECItem; typedef scoped_ptr_malloc< PLArenaPool, NSSDestroyer1 > ScopedPLArenaPool; } // namespace crypto #endif // CRYPTO_SCOPED_NSS_TYPES_H_