File: pools.h

package info (click to toggle)
malaga 7.12-7
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 3,040 kB
  • ctags: 2,283
  • sloc: ansic: 21,457; sh: 8,168; lisp: 504; makefile: 270
file content (62 lines) | stat: -rw-r--r-- 2,422 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* Copyright (C) 1995 Bjoern Beutel. */

/* Description. =============================================================*/

/* This module defines a new data type, "pool_t", for growing vectors of items 
 * of an arbitrary type. */

/* Types. ===================================================================*/

typedef struct pool *pool_t; /* The abstract data type. */

/* Functions. ===============================================================*/

extern pool_t new_pool( int_t item_size );
/* Create a new pool that records items of size ITEM_SIZE. */

extern void free_pool( pool_t *pool );
/* Free all memory used by *POOL. */

extern void clear_pool( pool_t pool );
/* Clear POOL. */

extern void *pool_to_vector( pool_t pool );
/* Return POOL as a C vector (contiguous memory).
 * The vector must be freed after use. */

extern void write_pool( pool_t pool, FILE *stream, string_t file_name );
/* Write POOL to STREAM. FILE_NAME is needed for error messages. */

extern void *get_pool_space( pool_t pool, int_t item_count, int_t *index );
/* Get space for ITEM_COUNT contiguous items in POOL.
 * Return its address as the function's result. 
 * Return its index in *INDEX, if INDEX != NULL. */

extern int_t pool_item_count( pool_t pool );
/* Return the number of the items in POOL. */

extern void *pool_item( pool_t pool, int_t index );
/* Return the address of item with INDEX in pool POOL,
 * or NULL if there is no such item. */

extern int_t pool_index( pool_t pool, const void *item );
/* Return the index of ITEM in POOL.
 * Report an error if ITEM doesn't exist in POOL. */

extern void *copy_to_pool( pool_t pool, 
                           const void *address,
                           int_t item_count, 
                           int_t *index );
/* Copy the vector *ADDRESS with ITEM_COUNT items into POOL.
 * The items of *ADDRESS must be of same size as the items in POOL.
 * Return the address of the copy as the function's result.
 * Return the index in *INDEX, if INDEX != NULL. */

extern string_t copy_string_to_pool( pool_t pool, 
                                     string_t string, 
                                     int_t *index );
/* Copy STRING into POOL, which must be a *string* pool.
 * Return the copy of the string as the function's result.
 * Return its index in *INDEX, if INDEX != NULL. */

/* End of file. =============================================================*/