1/* alloc.h
2   Header file for uuconf memory allocation routines.
3
4   Copyright (C) 1992 Ian Lance Taylor
5
6   This file is part of the Taylor UUCP uuconf library.
7
8   This library is free software; you can redistribute it and/or
9   modify it under the terms of the GNU Library General Public License
10   as published by the Free Software Foundation; either version 2 of
11   the License, or (at your option) any later version.
12
13   This library is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16   Library General Public License for more details.
17
18   You should have received a copy of the GNU Library General Public
19   License along with this library; if not, write to the Free Software
20   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
21
22   The author of the program may be contacted at ian@airs.com.
23   */
24
25/* This header file is private to the uuconf memory allocation
26   routines, and should not be included by any other files.  */
27
28/* We want to be able to keep track of allocated memory blocks, so
29   that we can free them up later.  This will let us free up all the
30   memory allocated to hold information for a system, for example.  We
31   do this by allocating large chunks and doling them out.  Calling
32   uuconf_malloc_block will return a pointer to a magic cookie which
33   can then be passed to uuconf_malloc and uuconf_free.  Passing the
34   pointer to uuconf_free_block will free all memory allocated for
35   that block.  */
36
37/* We allocate this much space in each block.  On most systems, this
38   will make the actual structure 1024 bytes, which may be convenient
39   for some types of memory allocators.  */
40#define CALLOC_SIZE (1008)
41
42/* This is the actual structure of a block.  */
43struct sblock
44{
45  /* Next block in linked list.  */
46  struct sblock *qnext;
47  /* Index of next free spot.  */
48  size_t ifree;
49  /* Last value returned by uuconf_malloc for this block.  */
50  pointer plast;
51  /* List of additional memory blocks.  */
52  struct sadded *qadded;
53  /* Buffer of data.  We put it in a union with a double to make sure
54     it is adequately aligned.  */
55  union
56    {
57      char ab[CALLOC_SIZE];
58      double l;
59    } u;
60};
61
62/* There is a linked list of additional memory blocks inserted by
63   uuconf_add_block.  */
64struct sadded
65{
66  /* The next in the list.  */
67  struct sadded *qnext;
68  /* The added block.  */
69  pointer padded;
70};
71