Is there a quick way to zero a struct/array

Started by GarageGothic, Tue 19/07/2005 12:21:30

Previous topic - Next topic

GarageGothic

Is there any quick way to clear out all values in a struct? Or do I have to do a

Code: ags
while (num <= maxnum) {
mystruct[num].array = 0;
num++:
}


on all values?

I'm not even sure, does it save memory if you reset the values to zero? I use a large amount of structs and arrays, and frankly I'm a bit worried about all the trash being stored in memory and in savegames.

Gilbert

Right, just use loops, there's no quick way as far as I know.
Quote from: GarageGothic on Tue 19/07/2005 12:21:30
I'm not even sure, does it save memory if you reset the values to zero?
No it doesn't matter, so organize your game's variables wisely. Unless it's something like Dynamic sprites or variables local to functions that can be destroyed.

GarageGothic

Ok thanks. Could the solution may be to use a room above 300 then so it wouldn't be state saved? And then use a global ints/struct for the few settings that are used later.

Pod


Gilbert

Quote from: GarageGothic on Tue 19/07/2005 13:07:08
Ok thanks. Could the solution may be to use a room above 300 then so it wouldn't be state saved? And then use a global ints/struct for the few settings that are used later.
Yes, this can be an idea.
Quote from: Pod on Tue 19/07/2005 21:36:02
can you "release" variables?
No, unless the vraiables are defined within functions, variables defined outside of functions cannot be "removed" ingame.

SMF spam blocked by CleanTalk