summaryrefslogtreecommitdiff
path: root/lib/buffer.h
diff options
context:
space:
mode:
authorJan Moskyto Matejka <mq@ucw.cz>2017-03-22 14:54:00 +0100
committerJan Moskyto Matejka <mq@ucw.cz>2017-03-22 14:54:00 +0100
commitead7b8f498ddefc0b7373cbba78f9a7ba1dddaa9 (patch)
tree86aa7f38e349b0bdaf31ab30eda0b36427f25c00 /lib/buffer.h
parentda3cf9eae3085d43a2299bae63e6ceb3828856a5 (diff)
parent61e501da895553abfd2424e56470ab2b457beac4 (diff)
Merge branch 'nexthop-merged' into int-new
Diffstat (limited to 'lib/buffer.h')
-rw-r--r--lib/buffer.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/buffer.h b/lib/buffer.h
index a8b11951..6fc18852 100644
--- a/lib/buffer.h
+++ b/lib/buffer.h
@@ -14,7 +14,7 @@
#include "sysdep/config.h"
#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))
#define BUFFER_INIT(v,pool,isize) \
@@ -46,6 +46,9 @@
#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; \