Refactor the internal symbols

This commit is contained in:
2022-08-22 14:18:38 +03:00
parent ca8251973e
commit 48bddb6db8
22 changed files with 195 additions and 262 deletions
+13 -13
View File
@@ -3,7 +3,7 @@
#include "include.h"
static void init_first(list_t* x, vnode_t v, vtype t) {
static void libcdsb_builtin_init(list_t* x, vnode_t v, vtype t) {
lnode_t* node = malloc(sizeof(*node));
node->next = nullptr;
@@ -16,7 +16,7 @@ static void init_first(list_t* x, vnode_t v, vtype t) {
}
static void push_next(list_t* x, vnode_t v, vtype t) {
static void libcdsb_builtin_push(list_t* x, vnode_t v, vtype t) {
lnode_t* node = malloc(sizeof(*node));
node->next = nullptr;
@@ -40,10 +40,10 @@ list_t list_copy(const list_t* s) {
if (is_null(c))
return x;
init_first(&x, vnode_duplicate(&c->node, c->type), c->type);
libcdsb_builtin_init(&x, vnode_duplicate(&c->node, c->type), c->type);
while (!is_null(c = c->next)) {
push_next(&x, vnode_duplicate(&c->node, c->type), c->type);
libcdsb_builtin_push(&x, vnode_duplicate(&c->node, c->type), c->type);
}
return x;
@@ -60,10 +60,10 @@ list_t* list_duplicate(const list_t* s) {
if (is_null(c))
return x;
init_first(x, vnode_duplicate(&c->node, c->type), c->type);
libcdsb_builtin_init(x, vnode_duplicate(&c->node, c->type), c->type);
while (!is_null(c = c->next)) {
push_next(x, vnode_duplicate(&c->node, c->type), c->type);
libcdsb_builtin_push(x, vnode_duplicate(&c->node, c->type), c->type);
}
return x;
@@ -79,10 +79,10 @@ void list_copy_init(list_t* x, const list_t* s) {
if (is_null(c))
return;
init_first(x, vnode_duplicate(&c->node, c->type), c->type);
libcdsb_builtin_init(x, vnode_duplicate(&c->node, c->type), c->type);
while (!is_null(c = c->next)) {
push_next(x, vnode_duplicate(&c->node, c->type), c->type);
libcdsb_builtin_push(x, vnode_duplicate(&c->node, c->type), c->type);
}
}
@@ -96,7 +96,7 @@ void list_extend(list_t* x, const list_t* s) {
return;
if (is_null(x->first)) {
init_first(x, vnode_duplicate(&c->node, c->type), c->type);
libcdsb_builtin_init(x, vnode_duplicate(&c->node, c->type), c->type);
c = c->next;
if (is_null(c))
@@ -104,7 +104,7 @@ void list_extend(list_t* x, const list_t* s) {
}
do {
push_next(x, vnode_duplicate(&c->node, c->type), c->type);
libcdsb_builtin_push(x, vnode_duplicate(&c->node, c->type), c->type);
} while (!is_null(c = c->next));
}
@@ -157,13 +157,13 @@ size_t list_slice(list_t* x, list_t* s, ssize_t i, size_t n, _Bool cut) {
else r -= n;
if (!cut) {
init_first(x, vnode_duplicate(&c->node, c->type), c->type);
libcdsb_builtin_init(x, vnode_duplicate(&c->node, c->type), c->type);
while ((c = c->next) != e) {
push_next(x, vnode_duplicate(&c->node, c->type), c->type);
libcdsb_builtin_push(x, vnode_duplicate(&c->node, c->type), c->type);
}
push_next(x, vnode_duplicate(&e->node, e->type), e->type);
libcdsb_builtin_push(x, vnode_duplicate(&e->node, e->type), e->type);
} else {
if (c->prev) {
c->prev->next = e->next;