aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/util.c b/util.c
index 1229f2c..63511a3 100644
--- a/util.c
+++ b/util.c
@@ -1,3 +1,4 @@
+#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
@@ -116,6 +117,15 @@ arrayaddbuf(struct array *a, const void *src, size_t n)
memcpy(arrayadd(a, n), src, n);
}
+void *
+arraylast(struct array *a, size_t n)
+{
+ if (a->len == 0)
+ return NULL;
+ assert(n <= a->len);
+ return (char *)a->val + a->len - n;
+}
+
void
listinsert(struct list *list, struct list *new)
{