Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
is this the correct way to delete a ds_list which contains ds_list in it?
Code:
//creating a dslist which holds other ds list
dslist = ds_list_create();
for(var i = 0;i<10;i++)
{
node = ds_list_create();
ds_list_add(node,i);
ds_list_add(dslist,node);
}
//deleting the dslists in the ds list
for(var i = 0;i<ds_list_size(dslist);i++)
{
ds_list_destroy(dslist[| i]);
}
ds_list_destroy(dslist);
This is a way to do it, looks correct to me. The alternative as suggested by GMWolf is to mark the internal data structures as such (using ds_list_mark_as_list in this case) and delete only the outer one.
This is a way to do it, looks correct to me. The alternative as suggested by GMWolf is to mark the internal data structures as such (using ds_list_mark_as_list in this case) and delete only the outer one.
ok this is has the same result as the previous code but I used ds_list_mark_as_list which makes it looks a bit smoother.
Code:
//creating a dslist which holds other ds list
dslist = ds_list_create();
for(var i = 0;i<10;i++)
{
node = ds_list_create();
ds_list_add(node,i);
ds_list_add(dslist,node);
ds_list_mark_as_list(dslist,i)
}
ds_list_destroy(dslist);
what happens with node? does this cause any memory leaks? do I have to clear it somewhere? or does the ds_list_destroy(dslist) take care of it due to the ds_list_mark_as_list()?