summaryrefslogtreecommitdiffhomepage
path: root/types.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2024-02-21 11:36:01 +0100
committerGitHub <noreply@github.com>2024-02-21 11:36:01 +0100
commit39109a9857247304067242044b44440583fbe960 (patch)
treec38739676757c60b8caa0c1f0401022e8aa9b44c /types.c
parent3f9811d2f7b730f1f1d030872ae1def7e8349be6 (diff)
parentee4af9b55cb4591e63c596af592abc33a8a8f315 (diff)
Merge pull request #189 from jow-/safe-iterators
vm: rework object iteration
Diffstat (limited to 'types.c')
-rw-r--r--types.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/types.c b/types.c
index eeac8c7..84a7b17 100644
--- a/types.c
+++ b/types.c
@@ -29,6 +29,11 @@
#include "ucode/vm.h"
#include "ucode/program.h"
+uc_list_t uc_object_iterators = {
+ .prev = &uc_object_iterators,
+ .next = &uc_object_iterators
+};
+
static char *uc_default_search_path[] = { LIB_SEARCH_PATH };
uc_parse_config_t uc_default_parse_config = {
@@ -888,6 +893,13 @@ ucv_array_length(uc_value_t *uv)
static void
ucv_free_object_entry(struct lh_entry *entry)
{
+ uc_list_foreach(item, &uc_object_iterators) {
+ uc_object_iterator_t *iter = (uc_object_iterator_t *)item;
+
+ if (iter->pos == entry)
+ iter->pos = entry->next;
+ }
+
free(lh_entry_k(entry));
ucv_put(lh_entry_v(entry));
}