1 /* Functions to support a pool of allocatable objects
2 Copyright (C) 1997-2014 Free Software Foundation, Inc.
3 Contributed by Daniel Berlin <dan@cgsoftware.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 typedef unsigned long ALLOC_POOL_ID_TYPE
;
25 typedef struct alloc_pool_list_def
27 struct alloc_pool_list_def
*next
;
31 typedef struct alloc_pool_def
34 #ifdef ENABLE_CHECKING
35 ALLOC_POOL_ID_TYPE id
;
37 size_t elts_per_block
;
39 /* These are the elements that have been allocated at least once and freed. */
40 alloc_pool_list returned_free_list
;
42 /* These are the elements that have not yet been allocated out of
43 the last block obtained from XNEWVEC. */
44 char* virgin_free_list
;
46 /* The number of elements in the virgin_free_list that can be
47 allocated before needing another block. */
48 size_t virgin_elts_remaining
;
50 size_t elts_allocated
;
52 size_t blocks_allocated
;
53 alloc_pool_list block_list
;
59 extern alloc_pool
create_alloc_pool (const char *, size_t, size_t);
60 extern void free_alloc_pool (alloc_pool
);
61 extern void empty_alloc_pool (alloc_pool
);
62 extern void free_alloc_pool_if_empty (alloc_pool
*);
63 extern void *pool_alloc (alloc_pool
) ATTRIBUTE_MALLOC
;
64 extern void pool_free (alloc_pool
, void *);
65 extern void dump_alloc_pool_statistics (void);