Alternate e697dbe9c5997e35395fe158628dd8c5209481da
for Visual Studio 2022 and Windows 11.
読み取り中…
検索中…
一致する文字列を見つけられません
FreightMemoryLeakCheck.cpp
[詳解]
1
5
6#include "pch.h"
8
9using namespace LeakCheck;
10
12{
13
14}
15
17{
18
19}
20
22{
23 return TRUE;
24}
25
27{
28 DoAction1 ();
29 DoAction2 ();
30 DoAction3 ();
31 DoAction4 ();
32 DoAction5 ();
33 DoAction6 ();
34
35 return TRUE;
36}
37
39{
40 OutputDebugString (_T ("FreightMemoryLeakCheck::DoAction1()---------->\n"));
42
43 alt::HeapMemory memory;
44 BOOL ret = memory.Create ();
45 if (!ret) return FALSE;
46
47 alt::skeleton::Freight<CHAR> freight1 (&memory);
48 alt::skeleton::Freight<CHAR> freight2 (&memory);
49 alt::skeleton::Freight<CHAR> freight3 (&memory);
50
51 return TRUE;
52}
53
55{
56 OutputDebugString (_T ("FreightMemoryLeakCheck::DoAction2()---------->\n"));
58
59 LPSTR lpszMessage = (LPSTR)"This is a sample text.";
60
61 alt::HeapMemory memory;
62 BOOL ret = memory.Create ();
63 if (!ret) return FALSE;
64
65 alt::skeleton::Freight<CHAR> freight1 (lpszMessage, lstrlenA (lpszMessage), &memory);
66 alt::skeleton::Freight<CHAR> freight2 (lpszMessage, lstrlenA (lpszMessage), &memory);
67 alt::skeleton::Freight<CHAR> freight3 (lpszMessage, lstrlenA (lpszMessage), &memory);
68
69 return TRUE;
70}
71
73{
74 OutputDebugString (_T ("FreightMemoryLeakCheck::DoAction3()---------->\n"));
76
77 LPSTR lpszMessage1 = (LPSTR)"This is a sample text No.1.";
78 LPSTR lpszMessage2 = (LPSTR)"This is a sample text No.2. ...";
79 LPSTR lpszMessage3 = (LPSTR)"This is a sample text No.3. ....";
80
81 alt::HeapMemory memory;
82 BOOL ret = memory.Create ();
83 if (!ret) return FALSE;
84
85 alt::skeleton::Freight<CHAR> freight (&memory);
86
87 freight.SetData (lpszMessage1, lstrlenA (lpszMessage1));
88 freight.SetData (lpszMessage2, lstrlenA (lpszMessage2));
89 freight.SetData (lpszMessage3, lstrlenA (lpszMessage3));
90
91 return TRUE;
92}
93
95{
96 OutputDebugString (_T ("FreightMemoryLeakCheck::DoAction4()---------->\n"));
98
99 LPSTR lpszMessage1 = (LPSTR)"This is a sample text No.1.";
100 LPSTR lpszMessage2 = (LPSTR)"This is a sample text No.2. ...";
101 LPSTR lpszMessage3 = (LPSTR)"This is a sample text No.3. ....";
102
103 alt::HeapMemory memory;
104 BOOL ret = memory.Create ();
105 if (!ret) return FALSE;
106
107 alt::skeleton::Freight<CHAR> freight1 (&memory);
108 alt::skeleton::Freight<CHAR> freight2 (lpszMessage2, lstrlenA (lpszMessage2), &memory);
109 alt::skeleton::Freight<CHAR> freight3 (&memory);
110
111 freight1.SetData (lpszMessage1, lstrlenA (lpszMessage1));
112 freight3.SetData (lpszMessage3, lstrlenA (lpszMessage3));
113
114 freight1 = freight2;
115 freight3 = freight2;
116
117 return TRUE;
118}
119
121{
122 OutputDebugString (_T ("FreightMemoryLeakCheck::DoAction5()---------->\n"));
124
125 LPSTR lpszMessage1 = (LPSTR)"This is a sample text No.1.";
126
127 alt::HeapMemory memory;
128 BOOL ret = memory.Create ();
129 if (!ret) return FALSE;
130
131 alt::skeleton::Freight<CHAR> freight1 (&memory);
132 freight1.SetData (lpszMessage1, lstrlenA (lpszMessage1));
133
134 alt::skeleton::Freight<CHAR> freight2 (freight1);
135
136 int cmp = strcmp (freight1.GetData (), freight2.GetData ());
137 0 == cmp ? _tprintf (_T ("ok.\n")) : _tprintf (_T ("NG. invalid seqno.\n"));
138
139 return TRUE;
140}
141
143{
144 OutputDebugString (_T ("FreightMemoryLeakCheck::DoAction6()---------->\n"));
146
147 LPSTR lpszMessage1 = (LPSTR)"This is a sample text No.1.";
148 LPSTR lpszMessage2 = (LPSTR)"This is a sample text No.2. ...";
149 LPSTR lpszMessage3 = (LPSTR)"This is a sample text No.3. ....";
150
151 alt::HeapMemory memory;
152 BOOL ret = memory.Create ();
153 if (!ret) return FALSE;
154
155 alt::skeleton::Freight<CHAR> freight1 (&memory);
156 freight1.SetData (lpszMessage1, lstrlenA (lpszMessage1));
157
158 alt::skeleton::Freight<CHAR> freight2 (&memory);
159
160 freight2 = freight1;
161
162 int cmp = strcmp (freight1.GetData (), freight2.GetData ());
163 0 == cmp ? _tprintf (_T ("ok.\n")) : _tprintf (_T ("NG. invalid seqno.\n"));
164
165 return TRUE;
166}
Freightのメモリーリークを確認します。
#define CRT_SET_DEBUG_FLAG
Definition: pch.h:23
プリコンパイル済みヘッダー ファイルです。
virtual ~FreightMemoryLeakCheck()
デストラクタ
virtual BOOL Init()
初期化処理
virtual BOOL DoAction()
メモリーリーク調査
ヒープメモリに関するAPIを集約したクラス
Definition: HeapMemory.h:46
BOOL APIENTRY Create(SIZE_T initialSize=0, SIZE_T maximumSize=0, DWORD dwOptions=0)
ヒープ領域の取得
Definition: HeapMemory.cpp:56
プリミティブな変数を管理するコンテナクラス
Definition: Freight.hpp:18
T *APIENTRY GetData() const
格納データの取得
Definition: Freight.hpp:100
VOID APIENTRY SetData(T *lpData, size_t size)
値の設定
Definition: Freight.hpp:78