TheMagician
Member
I read a JSON string into a ds_map using json_decode().
Inside there is a list of lists. Here is an overview over the hierarchy and the indices that GMS assigns to the data structures:
{map id 0
..[list id 3
....[list id 0]
....[list id 1]
....[list id 2]
..]
}
So far so good.
Now I copy list 3 into a new list using
ds_list_copy(list_new, 3);
This works as intended. The original list (id 3) gets copied into a new list (id 4) which now also contains the references/indices of lists 0,1,2.
However, when I now do
ds_list_clear(list_new);
GMS will not just remove the values 0,1,2 from the new list but will also destroy/free the corresponding lists!
Is that intended behavior?
I would have expected such a behavior from ds_list_destroy() because it also destroys any nested data structures but from my understanding ds_list_clear() should only empty the slots in the list?
Inside there is a list of lists. Here is an overview over the hierarchy and the indices that GMS assigns to the data structures:
{map id 0
..[list id 3
....[list id 0]
....[list id 1]
....[list id 2]
..]
}
So far so good.
Now I copy list 3 into a new list using
ds_list_copy(list_new, 3);
This works as intended. The original list (id 3) gets copied into a new list (id 4) which now also contains the references/indices of lists 0,1,2.
However, when I now do
ds_list_clear(list_new);
GMS will not just remove the values 0,1,2 from the new list but will also destroy/free the corresponding lists!
Is that intended behavior?
I would have expected such a behavior from ds_list_destroy() because it also destroys any nested data structures but from my understanding ds_list_clear() should only empty the slots in the list?
Last edited: