summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-09-30 22:24:58 +0200
committerTyge Løvset <[email protected]>2020-09-30 22:24:58 +0200
commitafda06cffcbfc4116b5b1e1deea188b5f56809d6 (patch)
tree8272a65e61ba2ce0d447c1c7188b2634d03b07b2
parentf21efc9bd4ac4fd104883280ad9f3eae14a95b22 (diff)
downloadSTC-modified-afda06cffcbfc4116b5b1e1deea188b5f56809d6.tar.gz
STC-modified-afda06cffcbfc4116b5b1e1deea188b5f56809d6.zip
Fixed a bug in clist_insert_after() when list is empty.
-rw-r--r--stc/clist.h2
-rw-r--r--stc/cptr.h2
2 files changed, 3 insertions, 1 deletions
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) \