"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/include/util/bumpalloc.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).

bumpalloc.h  (Hoard-3.12):bumpalloc.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.cs.umass.edu/~emery Author: Emery Berger, http://www.emeryberger.com
Copyright (c) 1998-2012 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 34 skipping to change at line 34
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef HOARD_BUMPALLOC_H #ifndef HOARD_BUMPALLOC_H
#define HOARD_BUMPALLOC_H #define HOARD_BUMPALLOC_H
/** /**
* @class BumpAlloc * @class BumpAlloc
* @brief Obtains memory in chunks and bumps a pointer through the chunks. * @brief Obtains memory in chunks and bumps a pointer through the chunks.
* @author Emery Berger <http://www.cs.umass.edu/~emery> * @author Emery Berger <http://www.emeryberger.com>
*/ */
#include "mallocinfo.h" #include "mallocinfo.h"
namespace Hoard { namespace Hoard {
template <int ChunkSize, template <int ChunkSize,
class SuperHeap> class SuperHeap>
class BumpAlloc : public SuperHeap { class BumpAlloc : public SuperHeap {
public: public:
enum { Alignment = HL::MallocInfo::Alignment }; enum { Alignment = HL::MallocInfo::Alignment };
BumpAlloc (void) BumpAlloc()
: _bump (NULL), : _bump (nullptr),
_remaining (0) _remaining (0)
{} {}
inline void * malloc (size_t sz) { inline void * malloc (size_t sz) {
if (sz < HL::MallocInfo::MinSize) { if (sz < HL::MallocInfo::MinSize) {
sz = HL::MallocInfo::MinSize; sz = HL::MallocInfo::MinSize;
} }
sz = HL::align<HL::MallocInfo::Alignment>(sz); sz = HL::align<HL::MallocInfo::Alignment>(sz);
// If there's not enough space left to fulfill this request, get // If there's not enough space left to fulfill this request, get
// another chunk. // another chunk.
skipping to change at line 71 skipping to change at line 71
refill(sz); refill(sz);
} }
if (_bump) { if (_bump) {
char * old = _bump; char * old = _bump;
_bump += sz; _bump += sz;
_remaining -= sz; _remaining -= sz;
assert ((size_t) old % Alignment == 0); assert ((size_t) old % Alignment == 0);
return old; return old;
} else { } else {
// We were unable to get memory. // We were unable to get memory.
return NULL; return nullptr;
} }
} }
/// Free is disabled (we only bump, never reclaim). /// Free is disabled (we only bump, never reclaim).
inline void free (void *) {} inline void free (void *) {}
private: private:
/// The bump pointer. /// The bump pointer.
char * _bump; char * _bump;
 End of changes. 5 change blocks. 
6 lines changed or deleted 6 lines changed or added

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