mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-15 05:48:33 +00:00
FS-10167: Added ks_list_delete_iterator() to delete the node at the current iterator position (only if available if iterator is active). Updated blade_session to reflect ks_list_t being internally thread-safe now.
This commit is contained in:
1 parent
f3aad1a661
commit
5d82a1b2e2
4 files changed
+39
-45
No files matched your search
@@ -471,6 +471,14 @@ extern "C" {
|
||||
*/
|
||||
KS_DECLARE(int) ks_list_delete_at(ks_list_t *restrict l, unsigned int pos);
|
||||
|
||||
/**
|
||||
* expunge an element at the current iterator position from the list.
|
||||
*
|
||||
* @param l list to operate
|
||||
* @return 0 on success. Negative value on failure
|
||||
*/
|
||||
KS_DECLARE(int) ks_list_delete_iterator(ks_list_t *restrict l);
|
||||
|
||||
/**
|
||||
* expunge an array of elements from the list, given their position range.
|
||||
*
|
||||
|
||||
@@ -645,6 +645,26 @@ KS_DECLARE(int) ks_list_delete_at(ks_list_t *restrict l, unsigned int pos) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
KS_DECLARE(int) ks_list_delete_iterator(ks_list_t *restrict l) {
|
||||
struct ks_list_entry_s *delendo;
|
||||
|
||||
if (!l->iter_active || l->iter_pos >= l->numels) return -1;
|
||||
|
||||
ks_rwl_write_lock(l->lock);
|
||||
|
||||
delendo = ks_list_findpos(l, l->iter_pos);
|
||||
|
||||
ks_list_drop_elem(l, delendo, l->iter_pos);
|
||||
|
||||
l->numels--;
|
||||
|
||||
ks_assert(ks_list_repOk(l));
|
||||
|
||||
ks_rwl_write_unlock(l->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
KS_DECLARE(int) ks_list_delete_range(ks_list_t *restrict l, unsigned int posstart, unsigned int posend) {
|
||||
struct ks_list_entry_s *lastvalid, *tmp, *tmp2;
|
||||
unsigned int numdel, midposafter, i;
|
||||
|
||||
Reference in new issue
Block a user