Skip to content

Commit bcc65c6

Browse files
authored
Rework test of pointers at GC to use malloc instead of C++ constructors (#3069)
***NO_CI***
1 parent 814487b commit bcc65c6

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/CLR/Core/GarbageCollector_Info.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,12 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateOld_Worker(void **ref)
214214

215215
if (dst)
216216
{
217-
RelocationRecord *ptr = new RelocationRecord();
217+
RelocationRecord *ptr = (RelocationRecord *)platform_malloc(sizeof(RelocationRecord));
218+
219+
if (!ptr)
220+
{
221+
return false;
222+
}
218223

219224
s_lstRecords.push_back(ptr);
220225

@@ -233,6 +238,8 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateOld_Worker(void **ref)
233238
#else
234239
CLR_Debug::Printf("Duplicate base OLD: %08x\r\n", ref);
235240
#endif
241+
// need to free the memory allocated for the record
242+
platform_free(ptr);
236243

237244
NANOCLR_DEBUG_STOP();
238245
}
@@ -247,6 +254,9 @@ bool CLR_RT_GarbageCollector::TestPointers_PopulateOld_Worker(void **ref)
247254
CLR_Debug::Printf("Some data points into a free list: %08x\r\n", dst);
248255
#endif
249256

257+
// need to free the memory allocated for the record
258+
platform_free(ptr);
259+
250260
NANOCLR_DEBUG_STOP();
251261
}
252262
}
@@ -263,7 +273,8 @@ void CLR_RT_GarbageCollector::TestPointers_PopulateOld()
263273
{
264274
RelocationRecord *ptr = *itLst;
265275

266-
delete ptr;
276+
// need to free the memory allocated for the record
277+
platform_free(ptr);
267278
}
268279

269280
s_lstRecords.clear();

0 commit comments

Comments
 (0)