From: Martin Mares Date: Mon, 22 Jul 2013 08:08:13 +0000 (+0200) Subject: gary: Added GARY_INIT_SPACE(_ZERO) X-Git-Tag: v5.99~79 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=dae6c248288949e909510d256fe498bd23cc68bf;p=libucw.git gary: Added GARY_INIT_SPACE(_ZERO) --- diff --git a/ucw/gary.h b/ucw/gary.h index 6b4adfb1..5630bc2f 100644 --- a/ucw/gary.h +++ b/ucw/gary.h @@ -1,7 +1,7 @@ /* * UCW Library -- A simple growing array of an arbitrary type * - * (c) 2010--2012 Martin Mares + * (c) 2010--2013 Martin Mares */ #ifndef _UCW_GARY_H @@ -20,6 +20,8 @@ struct gary_hdr { #define GARY_INIT(ptr, n) (ptr) = gary_init(sizeof(*(ptr)), (n), 0) #define GARY_INIT_ZERO(ptr, n) (ptr) = gary_init(sizeof(*(ptr)), (n), 1) +#define GARY_INIT_SPACE(ptr, n) do { GARY_INIT(ptr, n); (ptr)->num_elts = 0; } while (0) +#define GARY_INIT_SPACE_ZERO(ptr, n) do { GARY_INIT_ZERO(ptr, n); (ptr)->num_elts = 0; } while (0) #define GARY_FREE(ptr) do { if (ptr) xfree(GARY_HDR(ptr)); } while (0) #define GARY_SIZE(ptr) (GARY_HDR(ptr)->num_elts) #define GARY_RESIZE(ptr, n) ((ptr) = gary_set_size((ptr), (n)))