X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/359df77829d85c6a415220fb4f21d5331323c79f..c760149fcb65296defd1af967fbfa098bd83143a:/lmem.c diff --git a/lmem.c b/lmem.c index e443aa6..a56108a 100644 --- a/lmem.c +++ b/lmem.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: lmem.c,v 1.1 1999/12/22 16:02:52 mdw Exp $ + * $Id: lmem.c,v 1.2 2000/06/17 11:29:20 mdw Exp $ * * Locked memory allocation (Unix-specific) * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: lmem.c,v $ + * Revision 1.2 2000/06/17 11:29:20 mdw + * Add arena support. + * * Revision 1.1 1999/12/22 16:02:52 mdw * Interface to allocating `locked' memory (which isn't paged out). * @@ -52,11 +55,20 @@ # include #endif +#include #include #include #include "lmem.h" +/*----- Arena operations --------------------------------------------------*/ + +static void *aalloc(arena *a, size_t sz) { return l_alloc((lmem *)a, sz); } +static void afree(arena *a, void *p) { l_free((lmem *)a, p); } +static void apurge(arena *a) { l_purge((lmem *)a); } + +static arena_ops l_ops = { aalloc, arena_fakerealloc, afree, apurge }; + /*----- Main code ---------------------------------------------------------*/ /* --- @l_init@ --- * @@ -83,6 +95,7 @@ int l_init(lmem *lm, size_t sz) /* --- Preliminaries --- */ + lm->a.ops = &l_ops; lm->err = 0; /* --- Try making a secure locked passphrase buffer --- *