summaryrefslogtreecommitdiff
path: root/lib/buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/buffer.h')
-rw-r--r--lib/buffer.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/buffer.h b/lib/buffer.h
index 2a53f211..cd9bab86 100644
--- a/lib/buffer.h
+++ b/lib/buffer.h
@@ -13,10 +13,14 @@
#include "lib/resource.h"
#include "sysdep/config.h"
-#define BUFFER(type) struct { type *data; uint used, size; }
-
+#define BUFFER_(type) struct { type *data; uint used, size; }
+#define BUFFER_TYPE(v) typeof(* (v).data)
#define BUFFER_SIZE(v) ((v).size * sizeof(* (v).data))
+#ifndef PARSER
+#define BUFFER(type) BUFFER_(type)
+#endif
+
#define BUFFER_INIT(v,pool,isize) \
({ \
(v).used = 0; \
@@ -46,4 +50,14 @@
#define BUFFER_FLUSH(v) ({ (v).used = 0; })
+#define BUFFER_WALK(v,n) \
+ for (BUFFER_TYPE(v) *_n = (v).data, n; _n < ((v).data + (v).used) && (n = *_n, 1); _n++)
+
+#define BUFFER_SHALLOW_COPY(dst, src) \
+ ({ \
+ (dst).used = (src).used; \
+ (dst).size = (src).size; \
+ (dst).data = (src).data; \
+ })
+
#endif /* _BIRD_BUFFER_H_ */