CTR Pia  4.11.3
Game Communication Engine
common_MemoryLeakChecker.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: common_MemoryLeakChecker.h
4 
5  Copyright Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12  *---------------------------------------------------------------------------*/
13 
14 
15 #pragma once
16 
17 #include <pia/common/common_definitions.h>
18 
19 
20 namespace nn
21 {
22 namespace pia
23 {
24 namespace common
25 {
26 
27 
28 /*!
29 @brief This class is used to automatically detect memory leaks inside the Pia library.
30 
31 @date 2014-02-03 Improved the description of <tt>Set/Check</tt>.
32 */
34 {
35 public:
36 /*!
37 @brief Instantiates the object.
38 */
39  MemoryLeakChecker(void);
40 
41 
42 /*!
43 @brief Destroys the object.
44 */
45  ~MemoryLeakChecker(void);
46 
47 
48 /*!
49 @brief Sets the starting point to check for memory leaks.
50 
51 @details This API function is designed to be called prior to starting an initialization process on a Pia module that you suspect is leaking memory. Pia is designed to first initialize the <tt>common</tt> module, and then initialize the higher-level modules in sequence. If you suspect that higher-level modules, including the <tt><i>xxx</i></tt> module, are leaking memory, execute this API function prior to calling the <tt>nn::pia::<i>xxx</i>::Initialize</tt> function.
52 @details Do not call this function between the <tt>BeginSetup</tt> and <tt>EndSetup</tt> functions of each module.
53 
54 @return Returns a successful <tt>Result</tt> if the call completes without an error.
55 @retval ResultNotInitialized Returned if the <tt>nn::pia::common::Initialize</tt> function has not been called. Programming error. Fix your program so that this error is not returned.
56 @retval ResultInvalidState Returned if this function is called at the wrong time. Call the <tt>nn::pia::common::EndSetup</tt> function at regular intervals. Programming error. Fix your program so that this error is not returned.
57 
58 @see Check
59 
60 
61 
62 
63 
64 */
65  nn::Result Set(void);
66 
67 
68 /*!
69 @brief Determines whether a memory leak has occurred.
70 
71 @details This API function is designed to be called after finalizing a Pia module that you suspect is leaking memory. Pia is designed to finalize modules in sequence, starting with the highest-level modules. If you suspect that higher-level modules, including the <tt><i>xxx</i></tt> module, are leaking memory, execute this API function after calling the <tt>nn::pia::<i>xxx</i>::Finalize</tt> function.
72 @details Do not call this function between the <tt>BeginSetup</tt> and <tt>EndSetup</tt> functions of each module.
73 
74 @return Returns a successful <tt>Result</tt> if the call completes without an error and no memory leak is suspected.
75 @retval ResultMemoryLeak Returned if a memory leak is suspected. Programming error. Fix your program so that this error is not returned.
76 @retval ResultNotInitialized Returned if the <tt>nn::pia::common::Initialize</tt> function has not been called. Programming error. Fix your program so that this error is not returned.
77 @retval ResultInvalidState Returned if this function is called at the wrong time. Call the <tt>nn::pia::common::EndSetup</tt> function at regular intervals. Programming error. Fix your program so that this error is not returned.
78 
79 @see Set
80 
81 
82 
83 
84 
85 */
86  nn::Result Check(void) const;
87 
88 
89 private:
90 /*!
91 @brief This copy constructor is private.
92 */
94 
95 /*!
96 @brief This assignment operator is private.
97 */
98  MemoryLeakChecker& operator=(const MemoryLeakChecker&);
99 
100  // Maintain the amount of available memory.
101  u32 m_FreeSize;
102 };
103 }
104 }
105 } // end of namespace nn::pia::common
This class is used to automatically detect memory leaks inside the Pia library.
Definition: common_MemoryLeakChecker.h:33
Definition: assert.h:115
~MemoryLeakChecker(void)
Destroys the object.
nn::Result Check(void) const
Determines whether a memory leak has occurred.
MemoryLeakChecker(void)
Instantiates the object.
nn::Result Set(void)
Sets the starting point to check for memory leaks.