]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - gnu/libexec/uucp/libuuconf/alloc.h
This commit was generated by cvs2svn to compensate for changes in r53910,
[FreeBSD/FreeBSD.git] / gnu / libexec / uucp / libuuconf / alloc.h
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 or
23    c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
24    */
25
26 /* This header file is private to the uuconf memory allocation
27    routines, and should not be included by any other files.  */
28
29 /* We want to be able to keep track of allocated memory blocks, so
30    that we can free them up later.  This will let us free up all the
31    memory allocated to hold information for a system, for example.  We
32    do this by allocating large chunks and doling them out.  Calling
33    uuconf_malloc_block will return a pointer to a magic cookie which
34    can then be passed to uuconf_malloc and uuconf_free.  Passing the
35    pointer to uuconf_free_block will free all memory allocated for
36    that block.  */
37
38 /* We allocate this much space in each block.  On most systems, this
39    will make the actual structure 1024 bytes, which may be convenient
40    for some types of memory allocators.  */
41 #define CALLOC_SIZE (1008)
42
43 /* This is the actual structure of a block.  */
44 struct sblock
45 {
46   /* Next block in linked list.  */
47   struct sblock *qnext;
48   /* Index of next free spot.  */
49   size_t ifree;
50   /* Last value returned by uuconf_malloc for this block.  */
51   pointer plast;
52   /* List of additional memory blocks.  */
53   struct sadded *qadded;
54   /* Buffer of data.  We put it in a union with a double to make sure
55      it is adequately aligned.  */
56   union
57     {
58       char ab[CALLOC_SIZE];
59       double l;
60     } u;
61 };
62
63 /* There is a linked list of additional memory blocks inserted by
64    uuconf_add_block.  */
65 struct sadded
66 {
67   /* The next in the list.  */
68   struct sadded *qnext;
69   /* The added block.  */
70   pointer padded;
71 };