POV-Ray : Newsgroups : povray.general : best practice question : Re: best practice question Server Time
25 Apr 2024 12:06:49 EDT (-0400)
  Re: best practice question  
From: Alain Martel
Date: 10 Jun 2020 13:24:35
Message: <5ee11753$1@news.povray.org>
Le 2020-06-09 à 06:07, jr a écrit :
> hi,
> 
> I have a macro which expands to an array, eg
> 
> #macro mkArr(...)
> .....
> array [2] {...}
> #end
> 
> which gets assigned, repeatedly, to the same '#declare'd variable.  is this ok
> wrt memory management, or is it better to '#undef' the elements, and or the
> array, before replacing it wholesale?  is there a difference?  do 'mixed' arrays
> behave same as "normal" arrays?
> 
> 
> regards, jr.
> 
> 
Whenever you assign a new value to any variable, the new value simply 
replace the old one in the same memory space.
The only issue that may arise for memory management, is when you assign 
a string that don't always have the same length.

So, you don't need to #undef.

I don't know for mixed arrays.

You may need to #undef if you want to assign a new value of a different 
type like float to vector or string.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.