"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/include/hoard/thresholdheap.h" between
Hoard-3.12.tar.gz and Hoard-3.13.tar.gz

About: The Hoard memory allocator is a drop-in replacement for malloc() that can improve application performance, especially for multithreaded programs running on multiprocessors (hint: newer releases now part of the HeapLayers package).

thresholdheap.h  (Hoard-3.12):thresholdheap.h  (Hoard-3.13)
// -*- C++ -*- // -*- C++ -*-
/* /*
The Hoard Multiprocessor Memory Allocator The Hoard Multiprocessor Memory Allocator
www.hoard.org www.hoard.org
Author: Emery Berger, http://www.emeryberger.org Author: Emery Berger, http://www.emeryberger.org
Copyright (c) 1998-2015 Emery Berger Copyright (c) 1998-2018 Emery Berger
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
skipping to change at line 71 skipping to change at line 71
: _inUse (0), : _inUse (0),
_allocated (0), _allocated (0),
_maxAllocated (0) _maxAllocated (0)
{} {}
inline void * malloc (size_t sz) { inline void * malloc (size_t sz) {
// Look for an object of this size (exactly? larger?) // Look for an object of this size (exactly? larger?)
// in the cache. // in the cache.
void * ptr = _cache.remove(sz); void * ptr = _cache.remove(sz);
if (ptr == NULL) { if (ptr == nullptr) {
// If none found, allocate one and return it. // If none found, allocate one and return it.
ptr = SuperHeap::malloc (sz); ptr = SuperHeap::malloc (sz);
_allocated += SuperHeap::getSize(ptr); _allocated += SuperHeap::getSize(ptr);
if (_allocated > _maxAllocated) { if (_allocated > _maxAllocated) {
_maxAllocated = _allocated; _maxAllocated = _allocated;
} }
} }
_inUse += SuperHeap::getSize(ptr); _inUse += SuperHeap::getSize(ptr);
assert (SuperHeap::getSize(ptr) >= sz); assert (SuperHeap::getSize(ptr) >= sz);
assert ((size_t) ptr % Alignment == 0); assert ((size_t) ptr % Alignment == 0);
skipping to change at line 189 skipping to change at line 189
V ptr = theList.front(); V ptr = theList.front();
theList.pop_front(); theList.pop_front();
// If we have just removed the last element from the list, // If we have just removed the last element from the list,
// erase the key entry. // erase the key entry.
if (theList.empty()) { if (theList.empty()) {
theMap.erase (key); theMap.erase (key);
} }
return ptr; return ptr;
} }
} }
return NULL; return nullptr;
} }
// Remove one of the largest available objects. // Remove one of the largest available objects.
V removeLargest() { V removeLargest() {
// Get the last (largest) element. // Get the last (largest) element.
typename mapType::reverse_iterator i; typename mapType::reverse_iterator i;
i = theMap.rbegin(); i = theMap.rbegin();
// If we found one (in other words, the list is non-empty), // If we found one (in other words, the list is non-empty),
// remove it. // remove it.
if (i != theMap.rend()) { if (i != theMap.rend()) {
skipping to change at line 211 skipping to change at line 211
listType& theList = (*i).second; listType& theList = (*i).second;
V ptr = theList.front(); V ptr = theList.front();
theList.pop_front(); theList.pop_front();
// If we have just removed the last element from the list, // If we have just removed the last element from the list,
// erase the key entry. // erase the key entry.
if (theList.empty()) { if (theList.empty()) {
theMap.erase (key); theMap.erase (key);
} }
return ptr; return ptr;
} }
return NULL; return nullptr;
} }
}; };
class Cache : public CacheHelper<size_t, void *> {}; class Cache : public CacheHelper<size_t, void *> {};
/// Amount of memory in use by a client. /// Amount of memory in use by a client.
unsigned long _inUse; unsigned long _inUse;
/// Amount of memory currently allocated from the OS (we can free some). /// Amount of memory currently allocated from the OS (we can free some).
unsigned long _allocated; unsigned long _allocated;
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)