From afda06cffcbfc4116b5b1e1deea188b5f56809d6 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Wed, 30 Sep 2020 22:24:58 +0200 Subject: Fixed a bug in clist_insert_after() when list is empty. --- stc/clist.h | 2 +- stc/cptr.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/stc/clist.h b/stc/clist.h index 4ff9c114..67ed0586 100644 --- a/stc/clist.h +++ b/stc/clist.h @@ -237,7 +237,7 @@ STC_API size_t _clist_size(const clist_void* self); clist_##X##_insert_after(clist_##X* self, clist_##X##_iter_t pos, Value value) { \ clist_##X##_node_t* node = pos.val ? _clist_node(X, pos.val) : NULL; \ _c_clist_insert_after(self, X, node, value); \ - if (node == self->last && pos._state == 0) self->last = entry; \ + if (!node || node == self->last && pos._state == 0) self->last = entry; \ pos.val = &entry->value, pos._state = 0; return pos; \ } \ STC_API clist_##X##_iter_t \ diff --git a/stc/cptr.h b/stc/cptr.h index c3ab1f74..19543c96 100644 --- a/stc/cptr.h +++ b/stc/cptr.h @@ -149,6 +149,8 @@ typedef long atomic_count_t; } #endif +#define csptr_pointer_compare(x, y) ((x)->get - (y)->get) + #define using_csptr(...) c_MACRO_OVERLOAD(using_csptr, __VA_ARGS__) #define using_csptr_2(X, Value) \ -- cgit v1.2.3