/* -*-c-*-
*
- * $Id: dstr.h,v 1.10 1999/12/22 15:39:51 mdw Exp $
+ * $Id: dstr.h,v 1.11 2000/06/17 10:37:39 mdw Exp $
*
* Handle dynamically growing strings
*
/*----- Revision history --------------------------------------------------*
*
* $Log: dstr.h,v $
+ * Revision 1.11 2000/06/17 10:37:39 mdw
+ * Add support for arena management.
+ *
* Revision 1.10 1999/12/22 15:39:51 mdw
* Fix argument reuse in DPUTS.
*
#include <stdio.h>
#include <stdlib.h>
+#ifndef MLIB_ALLOC_H
+# include "alloc.h"
+#endif
+
+#ifndef MLIB_ARENA_H
+# include "arena.h"
+#endif
+
/*----- Data structures ---------------------------------------------------*/
typedef struct dstr {
char *buf; /* Pointer to string buffer */
size_t sz; /* Size of the buffer */
size_t len; /* Length of the string */
+ arena *a; /* Pointer to arena */
} dstr;
-#define DSTR_INIT { 0, 0, 0 } /* How to initialize one */
+#define DSTR_INIT { 0, 0, 0, &arena_stdlib } /* How to initialize one */
/*----- Functions provided ------------------------------------------------*/
_dd->buf = 0; \
_dd->sz = 0; \
_dd->len = 0; \
+ _dd->a = &arena_stdlib; \
} while (0)
/* --- @dstr_destroy@ --- *
#define DDESTROY(d) do { \
dstr *_d = (d); \
if (_d->buf) \
- free(_d->buf); \
+ x_free(_d->a, _d->buf); \
DCREATE(_d); \
} while (0)