diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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) { |