Skip to content

Commit

Permalink
fix: replace subinfos macros
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Oct 28, 2024
1 parent 51afe2b commit 76f8fb3
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/session/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,40 @@

#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;
}

static inline void _z_subscription_infos_elem_move(void *dst, void *src) {
static inline void _z_subscription_infos_elem_clear(void *e) { _z_noop_clear((_z_subscription_infos_t *)e); }

static inline void _z_subscription_infos_elem_copy(void *dst, const 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;
}
Expand Down

0 comments on commit 76f8fb3

Please sign in to comment.