chiark
/
gitweb
/
~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use @ATOM_HASH@ rather than digging in the @atom@ structure.
[mLib]
/
darray.h
diff --git
a/darray.h
b/darray.h
index c04ca8bd24c479a6650c45359ba43a64376d37f7..b8f17eb0499bf5418b23346b46c828abf00242d2 100644
(file)
--- a/
darray.h
+++ b/
darray.h
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: darray.h,v 1.
2 1999/10/29 22:59:22
mdw Exp $
+ * $Id: darray.h,v 1.
5 2000/06/17 10:37:39
mdw Exp $
*
* Dynamically growing dense arrays
*
*
* Dynamically growing dense arrays
*
@@
-30,6
+30,15
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: darray.h,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: darray.h,v $
+ * Revision 1.5 2000/06/17 10:37:39 mdw
+ * Add support for arena management.
+ *
+ * Revision 1.4 1999/12/10 23:42:04 mdw
+ * Change header file guard names.
+ *
+ * Revision 1.3 1999/11/05 14:32:43 mdw
+ * Minor change in argument naming.
+ *
* Revision 1.2 1999/10/29 22:59:22 mdw
* New array adjustment macros for unsigned arguments.
*
* Revision 1.2 1999/10/29 22:59:22 mdw
* New array adjustment macros for unsigned arguments.
*
@@
-38,8
+47,8
@@
*
*/
*
*/
-#ifndef DARRAY_H
-#define DARRAY_H
+#ifndef
MLIB_
DARRAY_H
+#define
MLIB_
DARRAY_H
#ifdef __cplusplus
extern "C" {
#ifdef __cplusplus
extern "C" {
@@
-51,11
+60,11
@@
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
-#ifndef ALLOC_H
+#ifndef
MLIB_
ALLOC_H
# include "alloc.h"
#endif
# include "alloc.h"
#endif
-#ifndef EXC_H
+#ifndef
MLIB_
EXC_H
# include "exc.h"
#endif
# include "exc.h"
#endif
@@
-98,6
+107,7
@@
typedef struct da_base {
size_t len; /* Length of useful portion */
size_t off; /* Offset of @v@ into space */
unsigned push, unshift; /* Pushes/unshifts since growth */
size_t len; /* Length of useful portion */
size_t off; /* Offset of @v@ into space */
unsigned push, unshift; /* Pushes/unshifts since growth */
+ arena *a; /* Pointer to allocation arena */
} da_base;
/* --- @DA_DECL@ --- *
} da_base;
/* --- @DA_DECL@ --- *
@@
-108,12
+118,12
@@
typedef struct da_base {
* Use: Declares a structure for decribing a dynamic array.
*/
* Use: Declares a structure for decribing a dynamic array.
*/
-#define DA_DECL(
atype, type)
\
- typedef struct
atype { da_base b; type *v; } atype
+#define DA_DECL(
type_v, type)
\
+ typedef struct
type_v { da_base b; type *v; } type_v
/*----- Initialization, creation and destruction --------------------------*/
/*----- Initialization, creation and destruction --------------------------*/
-#define DA_INIT { { 0, 0, 0, 0, 0
}, 0 } /* Standard initializer */
+#define DA_INIT { { 0, 0, 0, 0, 0
, &arena_stdlib }, 0 }
/* --- @DA_CREATE@ --- *
*
/* --- @DA_CREATE@ --- *
*
@@
-122,11
+132,12
@@
typedef struct da_base {
* Use: Initializes an array block.
*/
* Use: Initializes an array block.
*/
-#define DA_CREATE(a) do { \
- (a)->b.sz = (a)->b.len = 0; \
- (a)->b.off = 0; \
- (a)->b.push = (a)->b.unshift = 0; \
- (a)->v = 0; \
+#define DA_CREATE(aa) do { \
+ (aa)->b.sz = (aa)->b.len = 0; \
+ (aa)->b.off = 0; \
+ (aa)->b.push = (aa)->b.unshift = 0; \
+ (aa)->b.a = &arena_stdlib; \
+ (aa)->v = 0; \
} while (0)
/* --- @DA_DESTROY@ --- *
} while (0)
/* --- @DA_DESTROY@ --- *
@@
-136,10
+147,10
@@
typedef struct da_base {
* Use: Destroys an array. The array is left valid but empty.
*/
* Use: Destroys an array. The array is left valid but empty.
*/
-#define DA_DESTROY(a
) do {
\
- if ((a
)->v)
\
-
free((a)->v - (a)->b.off);
\
- DA_CREATE(a
);
\
+#define DA_DESTROY(a
a) do {
\
+ if ((a
a)->v)
\
+
x_free((aa)->b.a, (aa)->v - (aa)->b.off);
\
+ DA_CREATE(a
a);
\
} while (0)
/*----- Storage reservation -----------------------------------------------*/
} while (0)
/*----- Storage reservation -----------------------------------------------*/