Skip to content

Commit e9875f1

Browse files
Fix matching (#1069)
* refactor matching * format * make _rc_to_void consume pointer; add test for _rc_to_void; * fix interest replay * fix __z_get_interest_by_key_and_flags * simplify _z_optional_id_make_none * revert zenohd branch to eclipse-zenoh main
1 parent f30b6dc commit e9875f1

39 files changed

+802
-617
lines changed

include/zenoh-pico/collections/list.h

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ _z_list_t *_z_list_pop(_z_list_t *xs, z_element_free_f f_f, void **x);
5050

5151
_z_list_t *_z_list_find(const _z_list_t *xs, z_element_eq_f f_f, const void *e);
5252
_z_list_t *_z_list_drop_element(_z_list_t *list, _z_list_t *prev, z_element_free_f f_f);
53-
_z_list_t *_z_list_drop_filter(_z_list_t *xs, z_element_free_f f_f, z_element_eq_f c_f, const void *left);
53+
_z_list_t *_z_list_drop_filter(_z_list_t *xs, z_element_free_f f_f, z_element_eq_f c_f, const void *left,
54+
bool only_first);
5455

5556
_z_list_t *_z_list_clone(const _z_list_t *xs, z_element_clone_f d_f);
5657
void _z_list_free(_z_list_t **xs, z_element_free_f f_f);
@@ -79,8 +80,11 @@ void _z_list_free(_z_list_t **xs, z_element_free_f f_f);
7980
static inline name##_list_t *name##_list_drop_element(name##_list_t *l, name##_list_t *p) { \
8081
return _z_list_drop_element(l, p, name##_elem_free); \
8182
} \
82-
static inline name##_list_t *name##_list_drop_filter(name##_list_t *l, name##_eq_f c_f, const type *e) { \
83-
return _z_list_drop_filter(l, name##_elem_free, (z_element_eq_f)c_f, e); \
83+
static inline name##_list_t *name##_list_drop_first_filter(name##_list_t *l, name##_eq_f c_f, const type *e) { \
84+
return _z_list_drop_filter(l, name##_elem_free, (z_element_eq_f)c_f, e, true); \
85+
} \
86+
static inline name##_list_t *name##_list_drop_all_filter(name##_list_t *l, name##_eq_f c_f, const type *e) { \
87+
return _z_list_drop_filter(l, name##_elem_free, (z_element_eq_f)c_f, e, false); \
8488
} \
8589
static inline name##_list_t *name##_list_clone(name##_list_t *l) { return _z_list_clone(l, name##_elem_clone); } \
8690
static inline void name##_list_free(name##_list_t **l) { _z_list_free(l, name##_elem_free); }
@@ -108,39 +112,43 @@ size_t _z_slist_len(const _z_slist_t *node);
108112
_z_slist_t *_z_slist_pop(_z_slist_t *node, z_element_clear_f f_f);
109113
_z_slist_t *_z_slist_find(const _z_slist_t *node, z_element_eq_f c_f, const void *target_val);
110114
_z_slist_t *_z_slist_drop_element(_z_slist_t *list, _z_slist_t *prev, z_element_clear_f f_f);
111-
_z_slist_t *_z_slist_drop_filter(_z_slist_t *head, z_element_clear_f f_f, z_element_eq_f c_f, const void *target_val);
115+
_z_slist_t *_z_slist_drop_filter(_z_slist_t *head, z_element_clear_f f_f, z_element_eq_f c_f, const void *target_val,
116+
bool only_first);
112117
_z_slist_t *_z_slist_clone(const _z_slist_t *node, size_t value_size, z_element_copy_f d_f, bool use_elem_f);
113118
void _z_slist_free(_z_slist_t **node, z_element_clear_f f);
114119

115-
#define _Z_SLIST_DEFINE(name, type, use_elem_f) \
116-
typedef _z_slist_t name##_slist_t; \
117-
static inline name##_slist_t *name##_slist_new(void) { return NULL; } \
118-
static inline size_t name##_slist_len(const name##_slist_t *l) { return _z_slist_len(l); } \
119-
static inline bool name##_slist_is_empty(const name##_slist_t *l) { return _z_slist_is_empty(l); } \
120-
static inline name##_slist_t *name##_slist_next(const name##_slist_t *l) { return _z_slist_next(l); } \
121-
static inline type *name##_slist_value(const name##_slist_t *l) { return (type *)_z_slist_value(l); } \
122-
static inline name##_slist_t *name##_slist_push_empty(name##_slist_t *l) { \
123-
return _z_slist_push_empty(l, sizeof(type)); \
124-
} \
125-
static inline name##_slist_t *name##_slist_push(name##_slist_t *l, const type *e) { \
126-
return _z_slist_push(l, e, sizeof(type), name##_elem_copy, use_elem_f); \
127-
} \
128-
static inline name##_slist_t *name##_slist_push_back(name##_slist_t *l, const type *e) { \
129-
return _z_slist_push_back(l, e, sizeof(type), name##_elem_copy, use_elem_f); \
130-
} \
131-
static inline name##_slist_t *name##_slist_pop(name##_slist_t *l) { return _z_slist_pop(l, name##_elem_clear); } \
132-
static inline name##_slist_t *name##_slist_find(const name##_slist_t *l, name##_eq_f c_f, const type *e) { \
133-
return _z_slist_find(l, (z_element_eq_f)c_f, e); \
134-
} \
135-
static inline name##_slist_t *name##_slist_drop_element(name##_slist_t *l, name##_slist_t *p) { \
136-
return _z_slist_drop_element(l, p, name##_elem_clear); \
137-
} \
138-
static inline name##_slist_t *name##_slist_drop_filter(name##_slist_t *l, name##_eq_f c_f, const type *e) { \
139-
return _z_slist_drop_filter(l, name##_elem_clear, (z_element_eq_f)c_f, e); \
140-
} \
141-
static inline name##_slist_t *name##_slist_clone(name##_slist_t *l) { \
142-
return _z_slist_clone(l, sizeof(type), name##_elem_copy, use_elem_f); \
143-
} \
120+
#define _Z_SLIST_DEFINE(name, type, use_elem_f) \
121+
typedef _z_slist_t name##_slist_t; \
122+
static inline name##_slist_t *name##_slist_new(void) { return NULL; } \
123+
static inline size_t name##_slist_len(const name##_slist_t *l) { return _z_slist_len(l); } \
124+
static inline bool name##_slist_is_empty(const name##_slist_t *l) { return _z_slist_is_empty(l); } \
125+
static inline name##_slist_t *name##_slist_next(const name##_slist_t *l) { return _z_slist_next(l); } \
126+
static inline type *name##_slist_value(const name##_slist_t *l) { return (type *)_z_slist_value(l); } \
127+
static inline name##_slist_t *name##_slist_push_empty(name##_slist_t *l) { \
128+
return _z_slist_push_empty(l, sizeof(type)); \
129+
} \
130+
static inline name##_slist_t *name##_slist_push(name##_slist_t *l, const type *e) { \
131+
return _z_slist_push(l, e, sizeof(type), name##_elem_copy, use_elem_f); \
132+
} \
133+
static inline name##_slist_t *name##_slist_push_back(name##_slist_t *l, const type *e) { \
134+
return _z_slist_push_back(l, e, sizeof(type), name##_elem_copy, use_elem_f); \
135+
} \
136+
static inline name##_slist_t *name##_slist_pop(name##_slist_t *l) { return _z_slist_pop(l, name##_elem_clear); } \
137+
static inline name##_slist_t *name##_slist_find(const name##_slist_t *l, name##_eq_f c_f, const type *e) { \
138+
return _z_slist_find(l, (z_element_eq_f)c_f, e); \
139+
} \
140+
static inline name##_slist_t *name##_slist_drop_element(name##_slist_t *l, name##_slist_t *p) { \
141+
return _z_slist_drop_element(l, p, name##_elem_clear); \
142+
} \
143+
static inline name##_slist_t *name##_slist_drop_all_filter(name##_slist_t *l, name##_eq_f c_f, const type *e) { \
144+
return _z_slist_drop_filter(l, name##_elem_clear, (z_element_eq_f)c_f, e, false); \
145+
} \
146+
static inline name##_slist_t *name##_slist_drop_first_filter(name##_slist_t *l, name##_eq_f c_f, const type *e) { \
147+
return _z_slist_drop_filter(l, name##_elem_clear, (z_element_eq_f)c_f, e, true); \
148+
} \
149+
static inline name##_slist_t *name##_slist_clone(name##_slist_t *l) { \
150+
return _z_slist_clone(l, sizeof(type), name##_elem_copy, use_elem_f); \
151+
} \
144152
static inline void name##_slist_free(name##_slist_t **l) { _z_slist_free(l, name##_elem_clear); }
145153

146154
#ifdef __cplusplus

0 commit comments

Comments
 (0)