1 // Copyright 2020 PDFium 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 CORE_FXCRT_AUTONULLER_H_ 6 #define CORE_FXCRT_AUTONULLER_H_ 7 8 namespace fxcrt { 9 10 template <typename T> 11 class AutoNuller { 12 public: AutoNuller(T * location)13 explicit AutoNuller(T* location) : m_Location(location) {} ~AutoNuller()14 ~AutoNuller() { 15 if (m_Location) 16 *m_Location = nullptr; 17 } AbandonNullification()18 void AbandonNullification() { m_Location = nullptr; } 19 20 private: 21 T* m_Location; 22 }; 23 24 } // namespace fxcrt 25 26 using fxcrt::AutoNuller; 27 28 #endif // CORE_FXCRT_AUTONULLER_H_ 29