From: Martin Mares Date: Tue, 28 Jan 2014 17:28:20 +0000 (+0100) Subject: Gary: Type-agnostic push X-Git-Tag: v5.99~11 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=843c30cf741daee79f1955a56173c0b102e190f8;p=libucw.git Gary: Type-agnostic push --- 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;