Forum > Beginners
Create and free TStringList Question(Solved)
JLWest:
My question is on the TList1..3 Free statements. Can I Free them in any order?
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Var TList1: TStringList; TList2: TStringList; TList3: TStringList; Begin TList1:=TStringList.Create; TList2=TStringList.Create; TList3:=TStringList.Create; Try {Some processing using the 3 tstringlist} finally TList1.Free; TList2.Free; TList3.Free; end;
jamie:
In That case presented, I don't see a problem in freeing it in any order.
Blaazen:
If you do not have special reason, do not use prefix T for vars, it's confusing.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Var List1: TStringList; List2: TStringList; List3: TStringList;
JLWest:
I think Thaddy told me on global tstringList they had to be freed in reverse order of creation. Just wondering if it makes a difference inside a function.
Bart:
--- Quote from: JLWest on March 24, 2023, 11:04:12 pm ---I think Thaddy told me on global tstringList they had to be freed in reverse order of creation. Just wondering if it makes a difference inside a function.
--- End quote ---
That's just nonsense.
Bart
Navigation
[0] Message Index
[#] Next page