Skip to content

Commit f207140

Browse files
committed
- Now passing deletion test, to check there's no memory leaks when
destroying an LRUCache
1 parent 8755d79 commit f207140

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

21_LRUCacheUnitTest/main.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class LRUCacheTestApp final : public nbl::application_templates::MonoSystemMonoL
185185
{
186186
int* destroyCounter;
187187

188-
Foo(int* _destroyCounter) : destroyCounter(_destroyCounter) {}
188+
Foo(int* _destroyCounter) : destroyCounter(_destroyCounter){}
189189

190190
void operator=(Foo&& other)
191191
{
@@ -200,14 +200,15 @@ class LRUCacheTestApp final : public nbl::application_templates::MonoSystemMonoL
200200

201201
~Foo()
202202
{
203+
// Only count destructions of objects resident in Cache and not ones that happen right after moving out of
203204
if (destroyCounter)
204205
(*destroyCounter)++;
205206
}
206207
};
207208

208209
int destroyCounter = 0;
209210
{
210-
LRUCache<int, Foo> cache4(10u);
211+
ResizableLRUCache<int, Foo> cache4(10u);
211212
for (int i = 0; i < 10; i++)
212213
cache4.insert(i, Foo(&destroyCounter));
213214
int x = 0;

0 commit comments

Comments
 (0)