Browse Source

dtoolbase: More elegant fix for NeverFreeMemory memory leak

Better fix for 74983d19a41d5fbf006cb269d6b1adc9f705dc99 is to just switch to an std::multimap.  This couldn't go in the 1.10.x branch due to the risk of ABI change.
rdb 5 years ago
parent
commit
ae3d8c2663
2 changed files with 2 additions and 6 deletions
  1. 1 5
      dtool/src/dtoolbase/neverFreeMemory.I
  2. 1 1
      dtool/src/dtoolbase/neverFreeMemory.h

+ 1 - 5
dtool/src/dtoolbase/neverFreeMemory.I

@@ -80,11 +80,7 @@ Page(void *start, size_t size) :
  */
 INLINE bool NeverFreeMemory::Page::
 operator < (const NeverFreeMemory::Page &other) const {
-  if (_remaining != other._remaining) {
-    return _remaining < other._remaining;
-  } else {
-    return _next < other._next;
-  }
+  return _remaining < other._remaining;
 }
 
 /**

+ 1 - 1
dtool/src/dtoolbase/neverFreeMemory.h

@@ -57,7 +57,7 @@ private:
     size_t _remaining;
   };
 
-  typedef std::set<Page> Pages;
+  typedef std::multiset<Page> Pages;
   Pages _pages;
 
   size_t _total_alloc;