diff --git a/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h b/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h index 53f8968f86f..9a217389d82 100644 --- a/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h +++ b/BGL/include/CGAL/boost/graph/METIS/partition_dual_graph.h @@ -116,8 +116,8 @@ void partition_dual_graph(const TriangleMesh& tm, delete[] eptr; delete[] eind; - std::free(npart); - std::free(epart); + (std::free)(npart); + (std::free)(epart); } template diff --git a/BGL/include/CGAL/boost/graph/METIS/partition_graph.h b/BGL/include/CGAL/boost/graph/METIS/partition_graph.h index 08926a64116..42f8c240f01 100644 --- a/BGL/include/CGAL/boost/graph/METIS/partition_graph.h +++ b/BGL/include/CGAL/boost/graph/METIS/partition_graph.h @@ -151,8 +151,8 @@ void partition_graph(const TriangleMesh& tm, delete[] eptr; delete[] eind; - std::free(npart); - std::free(epart); + (std::free)(npart); + (std::free)(epart); } template diff --git a/CGAL_Core/include/CGAL/CORE/ExprRep.h b/CGAL_Core/include/CGAL/CORE/ExprRep.h index 0e721dda16a..a325930a2ab 100644 --- a/CGAL_Core/include/CGAL/CORE/ExprRep.h +++ b/CGAL_Core/include/CGAL/CORE/ExprRep.h @@ -595,7 +595,7 @@ public: } void operator delete( void *p, size_t ){ - MemoryPool::global_allocator().free(p); + (MemoryPool::global_allocator().free)(p); } private: @@ -1248,7 +1248,7 @@ void * AddSubRep::operator new( size_t size) template void AddSubRep::operator delete( void *p, size_t ) -{ MemoryPool >::global_allocator().free(p); } +{ (MemoryPool >::global_allocator().free)(p); } /// \typedef AddRep diff --git a/CGAL_Core/include/CGAL/CORE/Impl.h b/CGAL_Core/include/CGAL/CORE/Impl.h index 4ff8b4fa3d4..2e21aab5ac0 100644 --- a/CGAL_Core/include/CGAL/CORE/Impl.h +++ b/CGAL_Core/include/CGAL/CORE/Impl.h @@ -51,14 +51,14 @@ CGAL_INLINE_FUNCTION void *T::operator new( size_t size) \ { return MemoryPool::global_allocator().allocate(size); } \ CGAL_INLINE_FUNCTION void T::operator delete( void *p, size_t ) \ - { MemoryPool::global_allocator().free(p); } + { (MemoryPool::global_allocator().free)(p); } #define CORE_MEMORY_IMPL_TEMPLATE_WITH_ONE_ARG(C) \ template \ CGAL_INLINE_FUNCTION void *C::operator new( size_t size) \ { return MemoryPool >::global_allocator().allocate(size); } \ template \ CGAL_INLINE_FUNCTION void C::operator delete( void *p, size_t ) \ - { MemoryPool >::global_allocator().free(p); } + { (MemoryPool >::global_allocator().free)(p); } #endif // include some common header files diff --git a/CGAL_Core/include/CGAL/CORE/MemoryPool.h b/CGAL_Core/include/CGAL/CORE/MemoryPool.h index 2db3de8736e..1cfa96fa93d 100644 --- a/CGAL_Core/include/CGAL/CORE/MemoryPool.h +++ b/CGAL_Core/include/CGAL/CORE/MemoryPool.h @@ -73,7 +73,7 @@ public: void* allocate(std::size_t size); - void free(void* p); + void free BOOST_PREVENT_MACRO_SUBSTITUTION (void* p); // Access the corresponding static global allocator. static MemoryPool& global_allocator() { @@ -116,7 +116,7 @@ void* MemoryPool< T, nObjects >::allocate(std::size_t) { } template< class T, int nObjects > -void MemoryPool< T, nObjects >::free(void* t) { +void MemoryPool< T, nObjects >::free BOOST_PREVENT_MACRO_SUBSTITUTION (void* t) { CGAL_assertion(t != 0); if (t == 0) return; // for safety if(blocks.empty()){ diff --git a/CGAL_Core/include/CGAL/CORE/RealRep.h b/CGAL_Core/include/CGAL/CORE/RealRep.h index 1c5d0f13a40..f2ec1e90cb3 100644 --- a/CGAL_Core/include/CGAL/CORE/RealRep.h +++ b/CGAL_Core/include/CGAL/CORE/RealRep.h @@ -154,7 +154,7 @@ void * Realbase_for::operator new( size_t size) template void Realbase_for::operator delete( void *p, size_t ) -{ MemoryPool >::global_allocator().free(p); } +{ (MemoryPool >::global_allocator().free)(p); } typedef Realbase_for RealLong; typedef Realbase_for RealDouble; diff --git a/Classification/include/CGAL/Classification/Feature/Elevation.h b/Classification/include/CGAL/Classification/Feature/Elevation.h index 175b20b6a44..9ea9f267cc4 100644 --- a/Classification/include/CGAL/Classification/Feature/Elevation.h +++ b/Classification/include/CGAL/Classification/Feature/Elevation.h @@ -130,7 +130,7 @@ public: std::nth_element (z.begin(), z.begin() + (z.size() / 10), z.end()); dtm_x(i,j) = z[z.size() / 10]; } - dem.free(); + (dem.free)(); if (grid.width() * grid.height() > input.size()) values.resize (input.size(), compressed_float(0)); @@ -162,7 +162,7 @@ public: values[*it] = v; } } - dtm_x.free(); + (dtm_x.free)(); } diff --git a/Classification/include/CGAL/Classification/Feature/Height_above.h b/Classification/include/CGAL/Classification/Feature/Height_above.h index b59b108c1ac..3c85d27f91e 100644 --- a/Classification/include/CGAL/Classification/Feature/Height_above.h +++ b/Classification/include/CGAL/Classification/Feature/Height_above.h @@ -100,7 +100,7 @@ public: std::size_t J = grid.y(i); values[i] = float(dtm(I,J) - get (point_map, *(input.begin() + i)).z()); } - dtm.free(); + (dtm.free)(); } } diff --git a/Classification/include/CGAL/Classification/Feature/Height_below.h b/Classification/include/CGAL/Classification/Feature/Height_below.h index 22371934155..f71195dd348 100644 --- a/Classification/include/CGAL/Classification/Feature/Height_below.h +++ b/Classification/include/CGAL/Classification/Feature/Height_below.h @@ -100,7 +100,7 @@ public: std::size_t J = grid.y(i); values[i] = float(get (point_map, *(input.begin() + i)).z() - dtm(I,J)); } - dtm.free(); + (dtm.free)(); } } diff --git a/Classification/include/CGAL/Classification/Feature/Vertical_range.h b/Classification/include/CGAL/Classification/Feature/Vertical_range.h index 45b9c98d3ee..a4df1591c13 100644 --- a/Classification/include/CGAL/Classification/Feature/Vertical_range.h +++ b/Classification/include/CGAL/Classification/Feature/Vertical_range.h @@ -102,7 +102,7 @@ public: std::size_t J = grid.y(i); values[i] = dtm(I,J); } - dtm.free(); + (dtm.free)(); } } diff --git a/Classification/include/CGAL/Classification/Image.h b/Classification/include/CGAL/Classification/Image.h index 084e9572764..3bd915f0b5d 100644 --- a/Classification/include/CGAL/Classification/Image.h +++ b/Classification/include/CGAL/Classification/Image.h @@ -71,7 +71,7 @@ public: { } - void free() + void free BOOST_PREVENT_MACRO_SUBSTITUTION () { m_raw.reset(); m_sparse.reset(); diff --git a/Hash_map/include/CGAL/Hash_map/internal/chained_map.h b/Hash_map/include/CGAL/Hash_map/internal/chained_map.h index 27e38ee59d5..785443e2bee 100644 --- a/Hash_map/include/CGAL/Hash_map/internal/chained_map.h +++ b/Hash_map/include/CGAL/Hash_map/internal/chained_map.h @@ -45,7 +45,7 @@ class chained_map chained_map_elem* table; chained_map_elem* table_end; - chained_map_elem* free; + chained_map_elem* freelist; std::size_t table_size; std::size_t table_size_1; @@ -144,10 +144,10 @@ void chained_map::init_table(std::size_t n) std::allocator_traits::construct(alloc,table + i); } - free = table + t; + freelist = table + t; table_end = table + t + t/2; - for (Item p = table; p < free; ++p) + for (Item p = table; p < freelist; ++p) { p->succ = nullptr; p->k = nullkey; } @@ -161,10 +161,10 @@ inline void chained_map::insert(std::size_t x, T y) q->k = x; q->i = y; } else { - free->k = x; - free->i = y; - free->succ = q->succ; - q->succ = free++; + freelist->k = x; + freelist->i = y; + freelist->succ = q->succ; + q->succ = freelist++; } } @@ -214,7 +214,7 @@ T& chained_map::access(Item p, std::size_t x) // index x not present, insert it - if (free == table_end) // table full: rehash + if (freelist == table_end) // table full: rehash { rehash(); p = HASH(x); } @@ -225,7 +225,7 @@ T& chained_map::access(Item p, std::size_t x) return p->i; } - q = free++; + q = freelist++; q->k = x; init_inf(q->i); // initializes q->i to xdef q->succ = p->succ; @@ -246,7 +246,7 @@ chained_map::chained_map(const chained_map& D) { init_table(D.table_size); - for(Item p = D.table; p < D.free; ++p) + for(Item p = D.table; p < D.freelist; ++p) { if (p->k != nullkey || p >= D.table + D.table_size) { insert(p->k,p->i); //D.copy_inf(p->i); // see chapter Implementation @@ -258,7 +258,7 @@ chained_map::chained_map(chained_map&& D) noexcept(std::is_nothrow_move_constructible_v && std::is_nothrow_move_constructible_v) : table(std::exchange(D.table, nullptr)) , table_end(std::exchange(D.table_end, nullptr)) - , free(std::exchange(D.free, nullptr)) + , freelist(std::exchange(D.freelist, nullptr)) , table_size(std::exchange(D.table_size, 0)) , table_size_1(std::exchange(D.table_size_1, 0)) , alloc(std::move(D.alloc)) @@ -273,7 +273,7 @@ chained_map& chained_map::operator=(const chained_ma init_table(D.table_size); - for(Item p = D.table; p < D.free; ++p) + for(Item p = D.table; p < D.freelist; ++p) { if (p->k != nullkey || p >= D.table + D.table_size) { insert(p->k,p->i); //copy_inf(p->i); // see chapter Implementation @@ -290,7 +290,7 @@ chained_map& chained_map::operator=(chained_map::statistics() const std::size_t n = 0; for (Item p = table; p < table + table_size; ++p) if (p ->k != nullkey) ++n; - std::size_t used_in_overflow = free - (table + table_size ); + std::size_t used_in_overflow = freelist - (table + table_size ); n += used_in_overflow; std::cout << "number of entries: " << n << "\n"; std::cout << "fraction of entries in first position: " << diff --git a/Installation/include/CGAL/config.h b/Installation/include/CGAL/config.h index 3506137af1a..ff437a7f444 100644 --- a/Installation/include/CGAL/config.h +++ b/Installation/include/CGAL/config.h @@ -37,6 +37,13 @@ #endif #ifdef CGAL_INCLUDE_WINDOWS_DOT_H + +#if defined(_MSC_VER) && defined(_DEBUG) +// Include support for memory leak detection +// This is only available in debug mode and when _CRTDBG_MAP_ALLOC is defined. +// It will include which will redefine `malloc` and `free`. +# define _CRTDBG_MAP_ALLOC 1 +#endif // Mimic users including this file which defines min max macros // and other names leading to name clashes #include