1
/* Copyright (C) 1995 Bjoern Beutel. */
3
/* Description. =============================================================*/
5
/* This module defines a new data type, "pool_t", for growing vectors of items
6
* of an arbitrary type. */
8
/* Types. ===================================================================*/
10
typedef struct POOL_T *pool_t; /* The abstract data type. */
12
/* Functions. ===============================================================*/
14
extern pool_t new_pool( int_t item_size );
15
/* Create a new pool that records items of size ITEM_SIZE. */
17
extern void free_pool( pool_t *pool );
18
/* Free all memory used by *POOL. */
20
extern void clear_pool( pool_t pool );
23
extern void *pool_to_vector( pool_t pool );
24
/* Return POOL as a C vector (contiguous memory).
25
* The vector must be freed after use. */
27
extern void write_pool( pool_t pool, FILE *stream, string_t file_name );
28
/* Write POOL to STREAM. FILE_NAME is needed for error messages. */
30
extern void *get_pool_space( pool_t pool, int_t item_count, int_t *index );
31
/* Get space for ITEM_COUNT contiguous items in POOL.
32
* Return its address as the function's result.
33
* Return its index in *INDEX, if INDEX != NULL. */
35
extern int_t pool_item_count( pool_t pool );
36
/* Return the number of the items in POOL. */
38
extern void *pool_item( pool_t pool, int_t index );
39
/* Return the address of item with INDEX in pool POOL,
40
* or NULL if there is no such item. */
42
extern int_t pool_index( pool_t pool, void *item );
43
/* Return the index of ITEM in POOL.
44
* Report an error if ITEM doesn't exist in POOL. */
46
extern void *copy_to_pool( pool_t pool,
50
/* Copy the vector *ADDRESS with ITEM_COUNT items into POOL.
51
* The items of *ADDRESS must be of same size as the items in POOL.
52
* Return the address of the copy as the function's result.
53
* Return the index in *INDEX, if INDEX != NULL. */
55
extern string_t copy_string_to_pool( pool_t pool,
58
/* Copy STRING into POOL, which must be a _string_ pool.
59
* Return the copy of the string as the function's result.
60
* Return its index in *INDEX, if INDEX != NULL. */
62
/* End of file. =============================================================*/