// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * 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. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // // $Id: G4AllocatorPool.cc,v 1.6 2010/07/14 10:45:46 gcosmo Exp $ // GEANT4 tag $Name: global-V09-03-22 $ // // // ---------------------------------------------------------------------- // G4AllocatorPool // // Implementation file // // Author: G.Cosmo, November 2000 // #include "G4AllocatorPool.hh" // ************************************************************ // G4AllocatorPool constructor // ************************************************************ // G4AllocatorPool::G4AllocatorPool( unsigned int sz ) : esize(sznext; delete p; } head = 0; chunks = 0; nchunks = 0; } // ************************************************************ // Grow // ************************************************************ // void G4AllocatorPool::Grow() { // Allocate new chunk, organize it as a linked list of // elements of size 'esize' // G4PoolChunk* n = new G4PoolChunk(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); }