/* -*-c-*-
*
- * $Id: mparena.h,v 1.2 1999/12/10 23:28:59 mdw Exp $
+ * $Id: mparena.h,v 1.3 2000/06/17 11:35:48 mdw Exp $
*
* Allocation and freeing of MP buffers
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mparena.h,v $
+ * Revision 1.3 2000/06/17 11:35:48 mdw
+ * Overhaul to use mLib's arena system underneath.
+ *
* Revision 1.2 1999/12/10 23:28:59 mdw
* Memory allocation counting.
*
/*----- Header files ------------------------------------------------------*/
+#include <mLib/arena.h>
+
#ifndef CATACOMB_MPW_H
# include "mpw.h"
#endif
typedef struct mparena {
mparena_node *root;
unsigned n;
- struct mparena_ops *ops;
+ arena *a;
} mparena;
-/* --- @mparena_ops@ --- *
- *
- * Operations required for an arena memory manager. The default manager just
- * calls @xmalloc@ and @free@, although it's possible to envisage a more
- * paranoid implementation which allocates locked memory pages. Switch them
- * over with @mparena_setops@. It's usual to only do this when you've
- * attached your extra state to the end of the @mparena@ structure.
- */
-
-typedef struct mparena_ops {
- void *(*alloc)(mparena */*a*/, size_t /*sz*/);
- void (*free)(mparena */*a*/, void */*p*/);
-} mparena_ops;
-
-/*----- Magical constants -------------------------------------------------*/
+/*----- Standard arenas ---------------------------------------------------*/
-#define MPARENA_GLOBAL ((mparena *)0)
+extern mparena mparena_global;
+#define MPARENA_GLOBAL (&mparena_global)
-extern mparena_ops mparena_defaultops;
+extern mparena mparena_secure;
+#define MPARENA_SECURE (&mparena_secure)
/*----- Functions provided ------------------------------------------------*/
extern void mparena_create(mparena */*a*/);
-#define MPARENA_INIT { 0, 0, &mparena_defaultops }
+#define MPARENA_INIT { 0, 0, &arena_stdlib }
-/* --- @mparena_setops@ --- *
+/* --- @mparena_setarena@ --- *
*
- * Arguments: @mparena *a@ = pointer to arena block
- * @mparena_ops *ops@ = pointer to operations block or null
+ * Arguments: @mparena *a@ = pointer to MP arena block
+ * @arena *aa@ = pointer to arena
*
- * Returns: The previous operations block.
+ * Returns: ---
*
- * Use: Sets or queries the operations attached to an arena.
+ * Use: Sets the underlying arena for an MP arena.
*/
-extern mparena_ops *mparena_setops(mparena */*a*/, mparena_ops */*ops*/);
+extern void mparena_setarena(mparena */*a*/, arena */*aa*/);
/* --- @mparena_destroy@ --- *
*
*
* Use: Frees an MP arena, and all the vectors held within it. The
* blocks which are currently allocated can be freed into some
- * other arena.
+ * other MP arena, as long as the underlying arenas are the
+ * same.
*/
extern void mparena_destroy(mparena */*a*/);