3 * $Id: mpalloc.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
5 * Allocation and freeing of MP buffers
7 * (c) 1999 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
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.
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.
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,
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.2 1999/12/10 23:29:48 mdw
34 * Change header file guard names.
36 * Revision 1.1 1999/11/17 18:02:16 mdw
37 * New multiprecision integer arithmetic suite.
41 #ifndef CATACOMB_MPARENA_H
42 #define CATACOMB_MPARENA_H
48 /*----- Header files ------------------------------------------------------*/
50 #ifndef CATACOMB_MPW_H
54 /*----- Data structures ---------------------------------------------------*/
56 typedef struct mparena_node
{
57 struct mparena_node
*left
, *right
;
61 typedef struct mparena
{
65 /*----- Magical constants -------------------------------------------------*/
67 #define MPARENA_GLOBAL ((mparena *)0)
69 /*----- Functions provided ------------------------------------------------*/
71 /* --- @mparena_create@ --- *
73 * Arguments: @mparena *a@ = pointer to arena block
77 * Use: Initializes an MP arena so that blocks can be allocated from
81 extern void mparena_create(mparena */
*a*/
);
83 #define MPARENA_INIT { 0 }
85 /* --- @mparena_destroy@ --- *
87 * Arguments: @mparena *a@ = pointer to arena block
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
96 extern void mparena_destroy(mparena */
*a*/
);
98 /* --- @mp_alloc@ --- *
100 * Arguments: @mparena *a@ = pointer to arena block
101 * @size_t n@ = number of digits required
103 * Returns: Pointer to a suitably sized block.
105 * Use: Allocates a lump of data suitable for use as an array of MP
109 extern mpw
*mp_alloc(mparena */
*a*/
, size_t /*n*/);
111 /* --- @mp_free@ --- *
113 * Arguments: @mparena *a@ = pointer to arena block
114 * @mpw *v@ = pointer to allocated vector
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.
122 extern mpw
*mp_free(mparena */
*a*/
, mpw */
*v*/
);
124 /*----- That's all, folks -------------------------------------------------*/