// $Id: AllocatorPool.cpp,v 1.3 2007/05/24 14:39:11 hmd Exp $ // ============================================================================ // CVS tag $Name: $, version $Revision: 1.3 $ // ============================================================================ /** @file * Implementation file for the class GaudiUtils::AllocatorPool.h * This file is copied form Geant4 project * @date 2006-02-10 */ // ============================================================================ // // ******************************************************************** // * DISCLAIMER * // * * // * The following disclaimer summarizes all the specific disclaimers * // * of contributors to this software. The specific disclaimers,which * // * govern, are listed with their locations in: * // * http://cern.ch/geant4/license * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. * // * * // * This code implementation is the intellectual property of the * // * GEANT4 collaboration. * // * By copying, distributing or modifying the Program (or any work * // * based on the Program) you indicate your acceptance of this * // * statement, and all its terms. * // ******************************************************************** // // ---------------------------------------------------------------------- // G4AllocatorPool // // Implementation file // // Author: G.Cosmo, November 2000 // // ============================================================================ // Include files // ============================================================================ // GaudiKernel // ============================================================================ #include "GaudiKernel/AllocatorPool.h" // ============================================================================ // ************************************************************ // G4AllocatorPool constructor // ************************************************************ // GaudiUtils::AllocatorPool::AllocatorPool ( unsigned int sz ) : esize(sznext; delete p; } head = 0; chunks = 0; nchunks = 0; } // ************************************************************ // Grow // ************************************************************ // void GaudiUtils::AllocatorPool::Grow() { // Allocate new chunk, organize it as a linked list of // elements of size 'esize' // PoolChunk* n = new PoolChunk(csize); n->next = chunks; chunks = n; nchunks++; const int nelem = csize/esize; char* start = n->mem; char* last = &start[(nelem-1)*esize]; for (char* p=start; p(p)->next = reinterpret_cast(p+esize); } reinterpret_cast(last)->next = 0; head = reinterpret_cast(start); } // ============================================================================ // The END // ============================================================================