Add an internal-representation no-op function.
[u/mdw/catacomb] / mpalloc.h
1 /* -*-c-*-
2 *
3 * $Id: mpalloc.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
4 *
5 * Allocation and freeing of MP buffers
6 *
7 * (c) 1999 Straylight/Edgeware
8 */
9
10 /*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of Catacomb.
13 *
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
18 *
19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
23 *
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
28 */
29
30 /*----- Revision history --------------------------------------------------*
31 *
32 * $Log: mpalloc.h,v $
33 * Revision 1.2 1999/12/10 23:29:48 mdw
34 * Change header file guard names.
35 *
36 * Revision 1.1 1999/11/17 18:02:16 mdw
37 * New multiprecision integer arithmetic suite.
38 *
39 */
40
41 #ifndef CATACOMB_MPARENA_H
42 #define CATACOMB_MPARENA_H
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 /*----- Header files ------------------------------------------------------*/
49
50 #ifndef CATACOMB_MPW_H
51 # include "mpw.h"
52 #endif
53
54 /*----- Data structures ---------------------------------------------------*/
55
56 typedef struct mparena_node {
57 struct mparena_node *left, *right;
58 mpw *v;
59 } mparena_node;
60
61 typedef struct mparena {
62 mparena_node *root;
63 } mparena_arena;
64
65 /*----- Magical constants -------------------------------------------------*/
66
67 #define MPARENA_GLOBAL ((mparena *)0)
68
69 /*----- Functions provided ------------------------------------------------*/
70
71 /* --- @mparena_create@ --- *
72 *
73 * Arguments: @mparena *a@ = pointer to arena block
74 *
75 * Returns: ---
76 *
77 * Use: Initializes an MP arena so that blocks can be allocated from
78 * it.
79 */
80
81 extern void mparena_create(mparena */*a*/);
82
83 #define MPARENA_INIT { 0 }
84
85 /* --- @mparena_destroy@ --- *
86 *
87 * Arguments: @mparena *a@ = pointer to arena block
88 *
89 * Returns: ---
90 *
91 * Use: Frees an MP arena, and all the vectors held within it. The
92 * blocks which are currently allocated can be freed into some
93 * other arena.
94 */
95
96 extern void mparena_destroy(mparena */*a*/);
97
98 /* --- @mp_alloc@ --- *
99 *
100 * Arguments: @mparena *a@ = pointer to arena block
101 * @size_t n@ = number of digits required
102 *
103 * Returns: Pointer to a suitably sized block.
104 *
105 * Use: Allocates a lump of data suitable for use as an array of MP
106 * digits.
107 */
108
109 extern mpw *mp_alloc(mparena */*a*/, size_t /*n*/);
110
111 /* --- @mp_free@ --- *
112 *
113 * Arguments: @mparena *a@ = pointer to arena block
114 * @mpw *v@ = pointer to allocated vector
115 *
116 * Returns: ---
117 *
118 * Use: Returns an MP vector to an arena. It doesn't have to be
119 * returned to the arena from which it was allocated.
120 */
121
122 extern mpw *mp_free(mparena */*a*/, mpw */*v*/);
123
124 /*----- That's all, folks -------------------------------------------------*/
125
126 #ifdef __cplusplus
127 }
128 #endif
129
130 #endif