Is this a safe way to clear an array?
BlitzMax Forums/BlitzMax Programming/Is this a safe way to clear an array? test = Null?!
Sorry let me be more specific. I want to clear it for REUSE not totally clear it forever.
I want to clear it for REUSE not totally clear it forever.
The difference between what you're doing and what Vertex suggests is purely academic. Oh, ok. For byte, short, int, long, float and double it should work with MemClear(Array, Arraysize). For instances and strings too, but I dont't think, that GC is so clever, to detect this freeed resources.
cu olli
cu olli
Sorry let me be more specific. I want to clear it for REUSE not totally clear it forever.
You still got the flu? Thanks rich, I know I can do that, but I'm specifically uses slices becuase it's part of a larger piece of code that dynamically grows the arrays.
if you are going to reuse it, is it really necessary to clear it? maybe you could have a single element that designates 'clear' or 'full'
if arr[0]=1 then 'active' ( array is in use)
if arr[0] = 0 then 'clear' (don't use it)
or you could have another var.
arrayactive:int = true/false
if arr[0]=1 then 'active' ( array is in use)
if arr[0] = 0 then 'clear' (don't use it)
or you could have another var.
arrayactive:int = true/false
I see Grey, then I guess what you were doing before is probably the best solution.