projects
/
u
/
mdw
/
catacomb
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ec4825e
)
Add arena support.
author
mdw
<mdw>
Sat, 17 Jun 2000 11:29:38 +0000
(11:29 +0000)
committer
mdw
<mdw>
Sat, 17 Jun 2000 11:29:38 +0000
(11:29 +0000)
lmem.c
patch
|
blob
|
blame
|
history
lmem.h
patch
|
blob
|
blame
|
history
diff --git
a/lmem.c
b/lmem.c
index
e443aa6
..
a56108a
100644
(file)
--- a/
lmem.c
+++ b/
lmem.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-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)
*
*
* Locked memory allocation (Unix-specific)
*
@@
-30,6
+30,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: lmem.c,v $
/*----- 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).
*
* 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 <sys/mman.h>
#endif
# include <sys/mman.h>
#endif
+#include <mLib/arena.h>
#include <mLib/dstr.h>
#include <mLib/sub.h>
#include "lmem.h"
#include <mLib/dstr.h>
#include <mLib/sub.h>
#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@ --- *
/*----- Main code ---------------------------------------------------------*/
/* --- @l_init@ --- *
@@
-83,6
+95,7
@@
int l_init(lmem *lm, size_t sz)
/* --- Preliminaries --- */
/* --- Preliminaries --- */
+ lm->a.ops = &l_ops;
lm->err = 0;
/* --- Try making a secure locked passphrase buffer --- *
lm->err = 0;
/* --- Try making a secure locked passphrase buffer --- *
diff --git
a/lmem.h
b/lmem.h
index
8546dcf
..
8f24903
100644
(file)
--- a/
lmem.h
+++ b/
lmem.h
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: lmem.h,v 1.
1 1999/12/22 16:02:52
mdw Exp $
+ * $Id: lmem.h,v 1.
2 2000/06/17 11:29:38
mdw Exp $
*
* Locked memory allocation
*
*
* Locked memory allocation
*
@@
-30,6
+30,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: lmem.h,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: lmem.h,v $
+ * Revision 1.2 2000/06/17 11:29:38 mdw
+ * Add arena support.
+ *
* Revision 1.1 1999/12/22 16:02:52 mdw
* Interface to allocating `locked' memory (which isn't paged out).
*
* Revision 1.1 1999/12/22 16:02:52 mdw
* Interface to allocating `locked' memory (which isn't paged out).
*
@@
-46,6
+49,7
@@
#include <stddef.h>
#include <stddef.h>
+#include <mLib/arena.h>
#include <mLib/dstr.h>
/*----- Data structures ---------------------------------------------------*/
#include <mLib/dstr.h>
/*----- Data structures ---------------------------------------------------*/
@@
-72,6
+76,7
@@
enum {
/* --- Locked memory buffer state --- */
typedef struct lmem {
/* --- Locked memory buffer state --- */
typedef struct lmem {
+ arena a; /* Arena header block */
char *p; /* Pointer to locked buffer */
l_node *l; /* Pointer to block list */
size_t sz; /* Size of locked buffer */
char *p; /* Pointer to locked buffer */
l_node *l; /* Pointer to block list */
size_t sz; /* Size of locked buffer */
@@
-79,6
+84,13
@@
typedef struct lmem {
int err; char *emsg; /* Error indicators */
} lmem;
int err; char *emsg; /* Error indicators */
} lmem;
+/* --- Locked memory arena --- */
+
+typedef struct lmem_arena {
+ arena a;
+ lmem l;
+} lmem_arena;
+
/*----- Functions provided ------------------------------------------------*/
/* --- @l_init@ --- *
/*----- Functions provided ------------------------------------------------*/
/* --- @l_init@ --- *
@@
-151,6
+163,19
@@
extern void l_purge(lmem */*lm*/);
extern int l_report(lmem */*lm*/, dstr */*d*/);
extern int l_report(lmem */*lm*/, dstr */*d*/);
+/*----- Arena management --------------------------------------------------*/
+
+/* --- @l_arena@ --- *
+ *
+ * Arguments: @lmem_arena *l@ = pointer to arena block
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a locked-memory arena.
+ */
+
+extern void l_arena(lmem_arena */*l*/);
+
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus