kvec: Add kv_drop() which is to be used like (void)kv_pop(kvec)

This commit is contained in:
ZyX 2017-09-10 21:38:43 +03:00
parent 190c8516f5
commit e479f3b944

View File

@ -64,6 +64,14 @@
#define kv_max(v) ((v).capacity) #define kv_max(v) ((v).capacity)
#define kv_last(v) kv_A(v, kv_size(v) - 1) #define kv_last(v) kv_A(v, kv_size(v) - 1)
/// Drop last n items from kvec without resizing
///
/// Previously spelled as `(void)kv_pop(v)`, repeated n times.
///
/// @param[out] v Kvec to drop items from.
/// @param[in] n Number of elements to drop.
#define kv_drop(v, n) ((v).size -= (n))
#define kv_resize(v, s) \ #define kv_resize(v, s) \
((v).capacity = (s), \ ((v).capacity = (s), \
(v).items = xrealloc((v).items, sizeof((v).items[0]) * (v).capacity)) (v).items = xrealloc((v).items, sizeof((v).items[0]) * (v).capacity))