How to properly delete a list of structures?

Just starting out? Need help? Post your questions and find answers here.
AZJIO
Addict
Addict
Posts: 1361
Joined: Sun May 14, 2017 1:48 am

How to properly delete a list of structures?

Post by AZJIO »

Code: Select all

Structure Dirs
	List Dirs.Dirs()
	List Files.s()
EndStructure

NewList Files.Dirs()
1. If I create a recursive list of structures and then I need to delete the list with ClearList() or FreeList(), or delete an element with DeleteElement(), will the nested structures be handled automatically, or do I need to use ClearStructure() recursively?
2. If I create a recursive list of structures inside a procedure and then don't need it, will it be completely removed automatically when the procedure ends? Maybe it works for a procedure in a separate thread?
User avatar
mk-soft
Always Here
Always Here
Posts: 5406
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: How to properly delete a list of structures?

Post by mk-soft »

1) FreeList or ClearList is internally recursive.

2) In Procedure PB_NewList is called and on exit PB_FreeList is called. (See ASM or C-Backend Output)

3) Assigned objects in the list such as images, font, etc must be released with Free[Images,Font,etc] before clearing the list itself.

Code: Select all

Structure Dirs
	List Dirs.Dirs()
	List Files.s()
EndStructure

Procedure foo()
  Protected NewList Files.Dirs()
  ; Do any
EndProcedure

foo()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply