Skip to content

Commit

Permalink
Fix iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Jan 16, 2025
1 parent 0e410b6 commit 1131168
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/net/matching.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ _z_matching_listener_t _z_matching_listener_declare(_z_session_rc_t *zn, const _

z_result_t _z_matching_listener_entity_undeclare(_z_session_t *zn, _z_zint_t entity_id) {
_z_matching_listener_intmap_iterator_t iter = _z_matching_listener_intmap_iterator_make(&zn->_matching_listeners);
while (_z_matching_listener_intmap_iterator_next(&iter)) {
bool has_next = _z_matching_listener_intmap_iterator_next(&iter);
while (has_next) {
size_t key = _z_matching_listener_intmap_iterator_key(&iter);
_z_matching_listener_state_t *listener = _z_matching_listener_intmap_iterator_value(&iter);
_Z_DEBUG("_z_matching_listener_entity_undeclare: listener=%p", (void *)listener);
has_next = _z_matching_listener_intmap_iterator_next(&iter);
if (listener->entity_id == entity_id) {
_Z_DEBUG("_z_matching_listener_entity_undeclare: entity=%i, listener=%i", (int)entity_id, (int)key);
_z_remove_interest(zn, listener->interest_id);
Expand Down
1 change: 0 additions & 1 deletion tests/z_api_matching_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ void test_matching_sub(bool background) {

z_owned_publisher_t pub;
assert_ok(z_declare_publisher(z_session_loan(&s1), &pub, z_view_keyexpr_loan(&k_pub), NULL));
z_sleep_s(10);

z_owned_closure_matching_status_t closure;
z_closure_matching_status(&closure, on_receive, on_drop, (void*)(&context));
Expand Down
3 changes: 2 additions & 1 deletion tests/z_collections_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,13 @@ void int_map_iterator_deletion_test(void) {
_z_str_intmap_insert(&map, 40, _z_str_clone("D"));

_z_str_intmap_iterator_t iter = _z_str_intmap_iterator_make(&map);
_z_str_intmap_iterator_next(&iter);
for (size_t s = 4; s != 0; s--) {
assert(s == _z_str_intmap_len(&map));
_z_str_intmap_iterator_next(&iter);
size_t key = _z_str_intmap_iterator_key(&iter);
assert(strlen(_z_str_intmap_iterator_value(&iter)) == 1);
_z_str_intmap_remove(&map, key);
_z_str_intmap_iterator_next(&iter);
}
_z_str_intmap_clear(&map);
}
Expand Down

0 comments on commit 1131168

Please sign in to comment.