@@ -237,6 +237,11 @@ namespace RTE {
237237 }
238238
239239 void Entity::ClassInfo::FillPool (int fillAmount) {
240+ #ifdef __SANITIZE_ADDRESS__
241+ // If we have ASan, make this a no-op.
242+ (void )(fillAmount); // Silence warning about unused variable.
243+ #else
244+
240245 // Default to the set block allocation size if fillAmount is 0
241246 if (fillAmount <= 0 ) {
242247 fillAmount = m_PoolAllocBlockCount;
@@ -248,6 +253,7 @@ namespace RTE {
248253 m_AllocatedPool.push_back (m_Allocate ());
249254 }
250255 }
256+ #endif
251257 }
252258
253259 bool Entity::ClassInfo::IsClassOrChildClassOf (const ClassInfo* classInfoToCheck) const {
@@ -260,6 +266,13 @@ namespace RTE {
260266 }
261267
262268 void * Entity::ClassInfo::GetPoolMemory () {
269+ #ifdef __SANITIZE_ADDRESS__
270+ // If compiled with ASan, sidestep pooling and just use the allocator normally.
271+
272+ void * foundMemory = m_Allocate ();
273+ RTEAssert (foundMemory, " m_Allocate failed! to make memory!" );
274+ #else
275+
263276 std::lock_guard<std::mutex> guard (m_Mutex);
264277
265278 RTEAssert (IsConcrete (), " Trying to get pool memory of an abstract Entity class!" );
@@ -274,6 +287,7 @@ namespace RTE {
274287 m_AllocatedPool.pop_back ();
275288
276289 RTEAssert (foundMemory, " Could not find an available instance in the pool, even after increasing its size!" );
290+ #endif
277291
278292 // Keep track of the number of instances passed out
279293 m_InstancesInUse++;
@@ -285,8 +299,14 @@ namespace RTE {
285299 if (!returnedMemory) {
286300 return 0 ;
287301 }
302+
303+ #ifdef __SANITIZE_ADDRESS__
304+ // If compiled with ASan, sidestep pooling and just use the allocator normally.
305+ m_Deallocate (returnedMemory);
306+ #else
288307 std::lock_guard<std::mutex> guard (m_Mutex);
289308 m_AllocatedPool.push_back (returnedMemory);
309+ #endif
290310
291311 // Keep track of the number of instances passed in
292312 m_InstancesInUse--;
0 commit comments