1/* Functions to support a pool of allocatable objects
2   Copyright (C) 1997-2015 Free Software Foundation, Inc.
3   Contributed by Daniel Berlin <dan@cgsoftware.com>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3.  If not see
19<http://www.gnu.org/licenses/>.  */
20#ifndef ALLOC_POOL_H
21#define ALLOC_POOL_H
22
23typedef unsigned long ALLOC_POOL_ID_TYPE;
24
25typedef struct alloc_pool_list_def
26{
27  struct alloc_pool_list_def *next;
28}
29 *alloc_pool_list;
30
31typedef struct alloc_pool_def
32{
33  const char *name;
34#ifdef ENABLE_CHECKING
35  ALLOC_POOL_ID_TYPE id;
36#endif
37  size_t elts_per_block;
38
39  /* These are the elements that have been allocated at least once and freed.  */
40  alloc_pool_list returned_free_list;
41
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;
45
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;
49
50  size_t elts_allocated;
51  size_t elts_free;
52  size_t blocks_allocated;
53  alloc_pool_list block_list;
54  size_t block_size;
55  size_t elt_size;
56}
57 *alloc_pool;
58
59extern alloc_pool create_alloc_pool (const char *, size_t, size_t);
60extern void free_alloc_pool (alloc_pool);
61extern void empty_alloc_pool (alloc_pool);
62extern void free_alloc_pool_if_empty (alloc_pool *);
63extern void *pool_alloc (alloc_pool) ATTRIBUTE_MALLOC;
64extern void pool_free (alloc_pool, void *);
65extern void dump_alloc_pool_statistics (void);
66#endif
67