summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-01-05 13:14:12 +0100
committerTyge Løvset <[email protected]>2021-01-05 13:14:12 +0100
commit95798cc5e392aeb2a0b98b2ea1fa8220a8788d95 (patch)
tree45a3c0c31edf65d664bfdb4ca2b4e6b7d31991f5
parent2faa938ae200485c2f96e6550262dbc6dcc50f7a (diff)
downloadSTC-modified-95798cc5e392aeb2a0b98b2ea1fa8220a8788d95.tar.gz
STC-modified-95798cc5e392aeb2a0b98b2ea1fa8220a8788d95.zip
Changed macro c_defcon() to c_init(). Added clist_X_split() method.
-rw-r--r--docs/clist_api.md2
-rw-r--r--stc/ccommon.h2
-rw-r--r--stc/clist.h13
3 files changed, 14 insertions, 3 deletions
diff --git a/docs/clist_api.md b/docs/clist_api.md
index 01385a6c..7c5f78ee 100644
--- a/docs/clist_api.md
+++ b/docs/clist_api.md
@@ -79,6 +79,8 @@ clist_X_iter_t clist_X_splice_after(clist_X* self, clist_X_iter_t pos, clis
clist_X_iter_t clist_X_splice_front(clist_X* self, clist_X* other);
clist_X_iter_t clist_X_splice_back(clist_X* self, clist_X* other);
+clist_X clist_X_split_after(clist_X* self, clist_X_iter_t pos1, clist_X_iter_t pos2);
+
clist_X_iter_t clist_X_find(const clist_X* self, RawValue raw);
clist_X_iter_t clist_X_find_before(const clist_X* self,
clist_X_iter_t first, clist_X_iter_t finish, RawValue ref);
diff --git a/stc/ccommon.h b/stc/ccommon.h
index f8c32705..55839eaf 100644
--- a/stc/ccommon.h
+++ b/stc/ccommon.h
@@ -120,7 +120,7 @@
ctype##_push_n(self, __arr, sizeof __arr/sizeof *__arr); \
} while (0)
-#define c_defcon(ctype, c, ...) \
+#define c_init(ctype, c, ...) \
ctype c = ctype##_init(); c_push_items(&c, ctype, __VA_ARGS__)
#define c_convert(ctype1, c1, ctype2, put, c2ref) do { \
diff --git a/stc/clist.h b/stc/clist.h
index 440d7d18..941653ff 100644
--- a/stc/clist.h
+++ b/stc/clist.h
@@ -304,7 +304,7 @@ STC_API size_t _clist_size(const clist_void* self);
\
STC_DEF clist_##X##_iter_t \
clist_##X##_splice_after(clist_##X* self, clist_##X##_iter_t pos, clist_##X* other) { \
- clist_##X##_iter_t ret = clist_##X##_last(other); \
+ clist_##X##_iter_t it = clist_##X##_last(other); \
if (!pos.ref) \
self->last = other->last; \
else if (other->last) { \
@@ -314,7 +314,16 @@ STC_API size_t _clist_size(const clist_void* self);
if (node == self->last && pos._state == 0) self->last = other->last; \
} \
other->last = NULL; \
- ret._last = &self->last; return ret; \
+ it._last = &self->last; return it; \
+ } \
+\
+ STC_DEF clist_##X \
+ clist_##X##_split_after(clist_##X* self, clist_##X##_iter_t pos1, clist_##X##_iter_t pos2) { \
+ clist_##X##_node_t *node1 = _clist_node(X, pos1.ref), *next1 = node1->next, \
+ *node2 = _clist_node(X, pos2.ref); \
+ node1->next = node2->next, node2->next = next1; \
+ if (self->last == node2) self->last = node1; \
+ clist_##X list = {node2}; return list; \
} \
\
STC_INLINE int \