Update dbl list API
This commit is contained in:
@@ -29,23 +29,23 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) {
|
||||
}
|
||||
|
||||
// Handle first node
|
||||
const Str8Node *first_node = wapp_dbl_list_get(Str8, Str8Node, parts, 0);
|
||||
wapp_str8_copy_str8_capped(dst, first_node->item);
|
||||
Str8 *first_node = wapp_dbl_list_get(Str8, parts, 0);
|
||||
wapp_str8_copy_str8_capped(dst, first_node);
|
||||
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
const Str8Node *node = first_node;
|
||||
u64 node_index = 1;
|
||||
b8 running = node_index < parts->node_count;
|
||||
while (running && node->next) {
|
||||
node = node->next;
|
||||
if (node->item->size == 0) {
|
||||
continue;
|
||||
Str8 *node = first_node;
|
||||
u64 node_index = 1;
|
||||
b8 running = node_index < parts->node_count;
|
||||
while (running) {
|
||||
node = wapp_dbl_list_get(Str8, parts, node_index);
|
||||
if (node->size == 0) {
|
||||
goto CPATH_JOIN_LOOP_END;
|
||||
}
|
||||
|
||||
if (dst->size > 0) {
|
||||
char dst_last = wapp_str8_get(dst, dst->size - 1);
|
||||
char node_start = wapp_str8_get(node->item, 0);
|
||||
char node_start = wapp_str8_get(node, 0);
|
||||
b8 add_path_sep = dst_last != WAPP_PATH_SEP && node_start != WAPP_PATH_SEP;
|
||||
|
||||
if (add_path_sep) {
|
||||
@@ -53,8 +53,9 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) {
|
||||
}
|
||||
}
|
||||
|
||||
wapp_str8_concat_capped(dst, node->item);
|
||||
wapp_str8_concat_capped(dst, node);
|
||||
|
||||
CPATH_JOIN_LOOP_END:
|
||||
++node_index;
|
||||
running = node_index < parts->node_count;
|
||||
}
|
||||
@@ -106,7 +107,7 @@ Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels) {
|
||||
wapp_str8_push_back(output, absolute ? WAPP_PATH_SEP : '.');
|
||||
} else {
|
||||
for (u64 i = 0; i < levels; ++i) {
|
||||
wapp_dbl_list_pop_back(Str8, Str8Node, parts);
|
||||
wapp_dbl_list_pop_back(Str8, parts);
|
||||
}
|
||||
|
||||
u64 alignment = sizeof(void *) * 2;
|
||||
|
||||
Reference in New Issue
Block a user