common: update bluelib api usage

This commit is contained in:
2025-11-06 10:38:23 +00:00
parent faa9200bb1
commit b26c37c349
5 changed files with 47 additions and 42 deletions

View File

@@ -1,6 +1,6 @@
#include <blue/core/queue.h>
#include <blue/core/stringstream.h>
#include <blue/object/string.h>
#include <blue/ds/string.h>
#include <ivy/ident.h>
#include <stdlib.h>
#include <string.h>
@@ -20,16 +20,17 @@ struct ivy_ident *ivy_ident_create(void)
void ivy_ident_destroy(struct ivy_ident *ident)
{
b_queue_iterator it = {0};
b_queue_iterator_begin(&ident->id_parts, &it);
while (b_queue_iterator_is_valid(&it)) {
b_queue_entry *entry = b_queue_first(&ident->id_parts);
while (entry) {
struct ivy_ident_part *part
= b_unbox(struct ivy_ident_part, it.entry, p_entry);
b_queue_iterator_erase(&it);
= b_unbox(struct ivy_ident_part, entry, p_entry);
b_queue_entry *next = b_queue_next(entry);
b_queue_delete(&ident->id_parts, entry);
free(part->p_str);
free(part);
entry = next;
}
free(ident);
@@ -51,19 +52,18 @@ void ivy_ident_add_part(struct ivy_ident *ident, const char *s)
size_t ivy_ident_to_string(const struct ivy_ident *ident, char *out, size_t max)
{
b_stringstream strv;
b_stringstream_begin(&strv, out, max);
b_stringstream *strv = b_stringstream_create_with_buffer(out, max);
int i = 0;
b_queue_iterator it = {0};
b_queue_foreach (&it, &ident->id_parts) {
b_queue_entry *entry = b_queue_first(&ident->id_parts);
while (entry) {
if (i > 0) {
b_stringstream_add(&strv, ".");
b_stream_write_char(strv, '.');
}
struct ivy_ident_part *part
= b_unbox(struct ivy_ident_part, it.entry, p_entry);
b_stringstream_add(&strv, part->p_str);
= b_unbox(struct ivy_ident_part, entry, p_entry);
b_stream_write_string(strv, part->p_str, NULL);
i++;
}