Alternate e697dbe9c5997e35395fe158628dd8c5209481da
for Visual Studio 2022 and Windows 11.
読み取り中…
検索中…
一致する文字列を見つけられません
LinkedListMemoryLeakCheck.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 _tprintf (_T ("LinkedListMemoryLeakCheck::DoAction()\n"));
30
32
33 for (int i = 1; i <= 500; i++)
34 {
35 Data data (i);
36 linkedList.AddFirst (data);
37 _tprintf (_T ("now Add() value=%d counter is %d\r"), data.Get (), i);
38 Sleep (10);
39 }
40 _tprintf (_T ("\n"));
41
42 for (int i = 1000; i >= 501; i--)
43 {
44 Data data (i);
45 linkedList.AddLast (data);
46 _tprintf (_T ("now Add() value=%d counter is %d\r"), data.Get (), i);
47 Sleep (10);
48 }
49 _tprintf (_T ("\n"));
50
51 alt::skeleton::LinkedList<Data> linkedListCopy = linkedList;
52 linkedList.Clear ();
53
54 for (int i = 0; i < linkedListCopy.Size (); i++)
55 {
56 Data* value = linkedListCopy.Get (i);
57 ASSERT (i == value->Get ());
58 _tprintf (_T ("now Get()=%d counter is %d\r"), value->Get (), i);
59 Sleep (10);
60 }
61 _tprintf (_T ("\n"));
62
63 int i = 1;
64 for (auto itr : linkedListCopy)
65 {
66 ASSERT (i++ == itr);
67 _tprintf (_T ("now Get()=%d counter is %d\r"), itr.Get(), i);
68 Sleep (10);
69 }
70
71 i = 1;
72 for (auto& itr : linkedListCopy)
73 {
74 ASSERT (i++ == itr);
75 _tprintf (_T ("now Get()=%d counter is %d\r"), itr.Get(), i);
76 Sleep (10);
77 }
78
79 linkedListCopy.Clear ();
80
81 return TRUE;
82}
LinkedListのメモリーリークを確認します。
#define CRT_SET_DEBUG_FLAG
Definition: pch.h:23
プリコンパイル済みヘッダー ファイルです。
データ格納クラス
Definition: LeakCheck.h:15
virtual BOOL DoAction()
メモリーリーク調査
virtual ~LinkedListMemoryLeakCheck()
デストラクタ
ポインタによる連結リストを具現したクラス
Definition: LinkedList.hpp:106
T *APIENTRY Get(SIZE_T index) const
指定したインデックスの値を取得
Definition: LinkedList.hpp:179
VOID APIENTRY AddFirst(T &item)
LinkedList<T>へ値を追加
Definition: LinkedList.hpp:133
VOID APIENTRY Clear()
領域の開放
Definition: LinkedList.hpp:313
VOID APIENTRY AddLast(T &item)
LinkedList<T>へ値を追加
Definition: LinkedList.hpp:156
SIZE_T APIENTRY Size() const
サイズを取得
Definition: LinkedList.hpp:307