|
|
@@ -2173,7 +2173,7 @@ qi_value_t *qi_del(qi_state_t *state, qi_value_t *value, qi_value_t *index)
|
|
|
|
|
|
value->value.table.table->used = 0;
|
|
|
value->value.table.table->capacity = QI_TABLE_MIN_CAP;
|
|
|
-
|
|
|
+
|
|
|
value->value.table.table->entries = qi_calloc(value->value.table.table->capacity, sizeof(qi_table_entry_t));
|
|
|
|
|
|
qi_linkedlist_destroy(value->value.table.table->llh);
|
|
|
@@ -2997,18 +2997,24 @@ static qi_bool _qi_guarded_equals(qi_state_t *state, qi_size_t depth,
|
|
|
return fileno(a->value.file.fd) == fileno(b->value.file.fd);
|
|
|
|
|
|
case QI_LIST:
|
|
|
+ {
|
|
|
if (qi_list_contains(tempstack, a) || qi_list_contains(tempstack, b))
|
|
|
return true;
|
|
|
|
|
|
qi_list_push(tempstack, a);
|
|
|
qi_list_push(tempstack, b);
|
|
|
|
|
|
- if (a->value.list == b->value.list)
|
|
|
- return true;
|
|
|
-
|
|
|
qi_mutex_lock(a->mutex);
|
|
|
qi_mutex_lock(b->mutex);
|
|
|
|
|
|
+ if (a->value.list == b->value.list)
|
|
|
+ {
|
|
|
+ qi_mutex_unlock(a->mutex);
|
|
|
+ qi_mutex_unlock(b->mutex);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
if (qi_list_length(a->value.list) != qi_list_length(b->value.list))
|
|
|
{
|
|
|
qi_mutex_unlock(a->mutex);
|
|
|
@@ -3017,21 +3023,22 @@ static qi_bool _qi_guarded_equals(qi_state_t *state, qi_size_t depth,
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- for (qi_size_t i = 0; i < qi_list_length(a->value.list); i++)
|
|
|
+ qi_list_t *la = qi_list_copy(a->value.list);
|
|
|
+ qi_mutex_unlock(a->mutex);
|
|
|
+
|
|
|
+ qi_list_t *lb = qi_list_copy(b->value.list);
|
|
|
+ qi_mutex_unlock(b->mutex);
|
|
|
+
|
|
|
+ for (qi_size_t i = 0; i < qi_list_length(la); i++)
|
|
|
if (!_qi_guarded_equals(state, depth + 1, tempstack,
|
|
|
- qi_list_index(a->value.list, i),
|
|
|
- qi_list_index(b->value.list, i)))
|
|
|
+ qi_list_index(la, i),
|
|
|
+ qi_list_index(lb, i)))
|
|
|
{
|
|
|
- qi_mutex_unlock(a->mutex);
|
|
|
- qi_mutex_unlock(b->mutex);
|
|
|
-
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- qi_mutex_unlock(a->mutex);
|
|
|
- qi_mutex_unlock(b->mutex);
|
|
|
-
|
|
|
return true;
|
|
|
+ }
|
|
|
|
|
|
case QI_TUPLE:
|
|
|
if (a->value.list == b->value.list)
|
|
|
@@ -3049,18 +3056,24 @@ static qi_bool _qi_guarded_equals(qi_state_t *state, qi_size_t depth,
|
|
|
return true;
|
|
|
|
|
|
case QI_TABLE:
|
|
|
+ {
|
|
|
if (qi_list_contains(tempstack, a) || qi_list_contains(tempstack, b))
|
|
|
return true;
|
|
|
|
|
|
qi_list_push(tempstack, a);
|
|
|
qi_list_push(tempstack, b);
|
|
|
|
|
|
- if (a->value.table.table == b->value.table.table)
|
|
|
- return true;
|
|
|
-
|
|
|
qi_mutex_lock(a->mutex);
|
|
|
qi_mutex_lock(b->mutex);
|
|
|
|
|
|
+ if (a->value.table.table == b->value.table.table)
|
|
|
+ {
|
|
|
+ qi_mutex_unlock(a->mutex);
|
|
|
+ qi_mutex_unlock(b->mutex);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
if (qi_table_length(a->value.table.table) !=
|
|
|
qi_table_length(b->value.table.table))
|
|
|
{
|
|
|
@@ -3070,30 +3083,28 @@ static qi_bool _qi_guarded_equals(qi_state_t *state, qi_size_t depth,
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- qi_table_iterate(a->value.table.table, {
|
|
|
+ qi_table_t *ta = qi_table_copy(a->value.table.table);
|
|
|
+ qi_mutex_unlock(a->mutex);
|
|
|
+
|
|
|
+ qi_table_t *tb = qi_table_copy(b->value.table.table);
|
|
|
+ qi_mutex_unlock(b->mutex);
|
|
|
+
|
|
|
+ qi_table_iterate(ta, {
|
|
|
qi_value_t *a_value = entry.value;
|
|
|
- qi_value_t *b_value = qi_table_get(b->value.table.table, entry.key);
|
|
|
+ qi_value_t *b_value = qi_table_get(tb, entry.key);
|
|
|
if (!b_value)
|
|
|
{
|
|
|
- qi_mutex_unlock(a->mutex);
|
|
|
- qi_mutex_unlock(b->mutex);
|
|
|
-
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (!_qi_guarded_equals(state, depth + 1, tempstack, a_value, b_value))
|
|
|
{
|
|
|
- qi_mutex_unlock(a->mutex);
|
|
|
- qi_mutex_unlock(b->mutex);
|
|
|
-
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- qi_mutex_unlock(a->mutex);
|
|
|
- qi_mutex_unlock(b->mutex);
|
|
|
-
|
|
|
return true;
|
|
|
+ }
|
|
|
|
|
|
case QI_FUNCTION:
|
|
|
return strcmp(a->value.function.name, b->value.function.name) == 0 &&
|