http://halsvik.net/d/?/public/nbh.mac
I do not think I have functions that call eachother ending in stacking overflow.
I read it might be eating of memory.
I can not think of anything that might cause that besides my dynamic (increasing) array sub. It copies the old array to a temp array, deletes the old array. Then it creates a new array with 1 size larger, copies the data from the temp array and fills in the new element:
Code: Select all
|----------------------------------------------------------------------------
|SUB: AddToArray - Dynamically adds elements to an array.
|----------------------------------------------------------------------------
Sub AddToArray(string varname, string vartype, targID)
/declare i int local
/declare copyofarr[0] ${vartype} local
/if (${Defined[${varname}]}) {
/deletevar copyofarr
/declare copyofarr[${${varname}.Size}] ${vartype} local
/for i 1 to ${${varname}.Size}
/varset copyofarr[${i}] ${${varname}[${i}]}
/next i
/deletevar ${varname}
/declare ${varname}[${Math.Calc[${copyofarr.Size}+1]}] ${vartype} outer
/for i 1 to ${Math.Calc[${copyofarr.Size}]}
|/echo varset ${varname}[${i}] ${copyofarr[${i}]}
/varset ${varname}[${i}] ${copyofarr[${i}]}
/next i
/varset ${varname}[${${varname}.Size}] ${targID}
} else {
/declare ${varname}[1]}] ${vartype} outer
/varset ${varname}[1]}] ${targID}
}
/returnIs there a way to debug the memory usage to maybe pinpoint a memory leakage?
I have read through the manual, but is there an undocumented array that would allow for redimensioning keeping the data? (ala VisualBasics Redim Preserve)
Or just a nice ArrayList implementation would be nice :-) (for those aggro list, ignore lists etc..)
-Wolf5


