From d003e789e3bfc2d266b612dd5b959029d0e39079 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Mon, 28 Oct 2024 18:00:45 +0100 Subject: [PATCH] fix: replace subinfos macros --- src/session/subscription.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/session/subscription.c b/src/session/subscription.c index de0319ea7..95da3d790 100644 --- a/src/session/subscription.c +++ b/src/session/subscription.c @@ -32,23 +32,34 @@ #define _Z_SUBINFOS_VEC_SIZE 4 // Arbitrary initial size +// Subscription infos typedef struct { _z_sample_handler_t callback; void *arg; } _z_subscription_infos_t; -static inline z_result_t _z_subscription_infos_copy(_z_subscription_infos_t *dst, const _z_subscription_infos_t *src) { - *dst = *src; - return _Z_RES_OK; -} - static inline void _z_subscription_infos_elem_move(void *dst, void *src) { *(_z_subscription_infos_t *)dst = *(_z_subscription_infos_t *)src; } -_Z_ELEM_DEFINE(_z_subscription_infos, _z_subscription_infos_t, _z_noop_size, _z_noop_clear, _z_subscription_infos_copy) -_Z_SVEC_DEFINE(_z_subscription_infos, _z_subscription_infos_t) +typedef _z_svec_t _z_subscription_infos_svec_t; +static inline _z_subscription_infos_svec_t _z_subscription_infos_svec_make(size_t capacity) { + return _z_svec_make(capacity, sizeof(_z_subscription_infos_t)); +} +static inline size_t _z_subscription_infos_svec_len(const _z_subscription_infos_svec_t *v) { return _z_svec_len(v); } + +static inline _Bool _z_subscription_infos_svec_append(_z_subscription_infos_svec_t *v, + const _z_subscription_infos_t *e) { + return _z_svec_append(v, e, _z_subscription_infos_elem_move, sizeof(_z_subscription_infos_t)); +} +static inline _z_subscription_infos_t *_z_subscription_infos_svec_get(const _z_subscription_infos_svec_t *v, + size_t pos) { + return (_z_subscription_infos_t *)_z_svec_get(v, pos, sizeof(_z_subscription_infos_t)); +} + +static inline void _z_subscription_infos_svec_release(_z_subscription_infos_svec_t *v) { _z_svec_release(v); } +// Subscription bool _z_subscription_eq(const _z_subscription_t *other, const _z_subscription_t *this_) { return this_->_id == other->_id; }