From 843c30cf741daee79f1955a56173c0b102e190f8 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 28 Jan 2014 18:28:20 +0100 Subject: [PATCH] Gary: Type-agnostic push --- ucw/gary.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ucw/gary.h b/ucw/gary.h index 1c5a647a..e2e29520 100644 --- a/ucw/gary.h +++ b/ucw/gary.h @@ -77,6 +77,15 @@ static inline void gary_free(void *ptr) } } +/* Type-agnostic interface. Currently it's recommended for internal use only. */ + +#define GARY_PUSH_GENERIC(ptr) ({ \ + struct gary_hdr *_h = GARY_HDR(ptr); \ + void *_c = (byte *)(ptr) + _h->num_elts++ * _h->elt_size; \ + if (_h->num_elts > _h->have_space) \ + (ptr) = gary_push_helper((ptr), 1, (byte **) &_c); \ + _c; }) + /* gary-mp.c */ struct mempool; -- 2.39.2