3 * $Id: mpalloc.h,v 1.1 1999/11/17 18:02:16 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.1 1999/11/17 18:02:16 mdw
34 * New multiprecision integer arithmetic suite.
45 /*----- Header files ------------------------------------------------------*/
51 /*----- Data structures ---------------------------------------------------*/
53 typedef struct mparena_node
{
54 struct mparena_node
*left
, *right
;
58 typedef struct mparena
{
62 /*----- Magical constants -------------------------------------------------*/
64 #define MPARENA_GLOBAL ((mparena *)0)
66 /*----- Functions provided ------------------------------------------------*/
68 /* --- @mparena_create@ --- *
70 * Arguments: @mparena *a@ = pointer to arena block
74 * Use: Initializes an MP arena so that blocks can be allocated from
78 extern void mparena_create(mparena */
*a*/
);
80 #define MPARENA_INIT { 0 }
82 /* --- @mparena_destroy@ --- *
84 * Arguments: @mparena *a@ = pointer to arena block
88 * Use: Frees an MP arena, and all the vectors held within it. The
89 * blocks which are currently allocated can be freed into some
93 extern void mparena_destroy(mparena */
*a*/
);
95 /* --- @mp_alloc@ --- *
97 * Arguments: @mparena *a@ = pointer to arena block
98 * @size_t n@ = number of digits required
100 * Returns: Pointer to a suitably sized block.
102 * Use: Allocates a lump of data suitable for use as an array of MP
106 extern mpw
*mp_alloc(mparena */
*a*/
, size_t /*n*/);
108 /* --- @mp_free@ --- *
110 * Arguments: @mparena *a@ = pointer to arena block
111 * @mpw *v@ = pointer to allocated vector
115 * Use: Returns an MP vector to an arena. It doesn't have to be
116 * returned to the arena from which it was allocated.
119 extern mpw
*mp_free(mparena */
*a*/
, mpw */
*v*/
);
121 /*----- That's all, folks -------------------------------------------------*/