1132718Skan/* Functions to support a pool of allocatable objects 2132718Skan Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004 3132718Skan Free Software Foundation, Inc. 4132718Skan Contributed by Daniel Berlin <dan@cgsoftware.com> 5132718Skan 6132718SkanThis file is part of GCC. 7132718Skan 8132718SkanGCC is free software; you can redistribute it and/or modify 9132718Skanit under the terms of the GNU General Public License as published by 10132718Skanthe Free Software Foundation; either version 2, or (at your option) 11132718Skanany later version. 12132718Skan 13132718SkanGCC is distributed in the hope that it will be useful, 14132718Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of 15132718SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16132718SkanGNU General Public License for more details. 17132718Skan 18132718SkanYou should have received a copy of the GNU General Public License 19132718Skanalong with GCC; see the file COPYING. If not, write to 20169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 21169689SkanBoston, MA 02110-1301, USA. */ 22132718Skan#ifndef ALLOC_POOL_H 23132718Skan#define ALLOC_POOL_H 24132718Skan 25132718Skantypedef unsigned long ALLOC_POOL_ID_TYPE; 26132718Skan 27132718Skantypedef struct alloc_pool_list_def 28132718Skan{ 29132718Skan struct alloc_pool_list_def *next; 30132718Skan} 31132718Skan *alloc_pool_list; 32132718Skan 33132718Skantypedef struct alloc_pool_def 34132718Skan{ 35132718Skan const char *name; 36132718Skan#ifdef ENABLE_CHECKING 37132718Skan ALLOC_POOL_ID_TYPE id; 38132718Skan#endif 39132718Skan size_t elts_per_block; 40132718Skan alloc_pool_list free_list; 41132718Skan size_t elts_allocated; 42132718Skan size_t elts_free; 43132718Skan size_t blocks_allocated; 44132718Skan alloc_pool_list block_list; 45132718Skan size_t block_size; 46132718Skan size_t elt_size; 47132718Skan} 48132718Skan *alloc_pool; 49132718Skan 50132718Skanextern alloc_pool create_alloc_pool (const char *, size_t, size_t); 51132718Skanextern void free_alloc_pool (alloc_pool); 52169689Skanextern void free_alloc_pool_if_empty (alloc_pool *); 53132718Skanextern void *pool_alloc (alloc_pool); 54132718Skanextern void pool_free (alloc_pool, void *); 55132718Skanextern void dump_alloc_pool_statistics (void); 56132718Skan#endif 57