function to free elements of the string list.

Note: Pointers that are allocated will never go out of scope. Pointers
that are assigned (=>) will be deallocated/disaccociated like allocatables
that go out of scope
This commit is contained in:
Martin Diehl 2018-06-26 18:46:52 +02:00
parent b907acfbfa
commit 92bcf3a7aa
1 changed files with 21 additions and 17 deletions

View File

@ -24,6 +24,7 @@ module config
contains
procedure :: add => add
procedure :: show => show
procedure :: free => free
procedure :: keyExists => keyExists
procedure :: countKeys => countKeys
@ -166,8 +167,9 @@ subroutine config_init()
end subroutine config_init
!--------------------------------------------------------------------------------------------------
!> @brief parses the homogenization part in the material configuration file
!> @brief parses the material.config file
!--------------------------------------------------------------------------------------------------
subroutine parseFile(line,&
sectionNames,part,fileUnit)
@ -229,6 +231,7 @@ subroutine parseFile(line,&
call part(s)%show()
end do
end if
end subroutine parseFile
!--------------------------------------------------------------------------------------------------
@ -283,23 +286,24 @@ end subroutine show
!--------------------------------------------------------------------------------------------------
!> @brief deallocates all elements of a given list
!> @details Strings are printed in order of insertion (FIFO)
!> @brief cleans entire list
!> @details list head is remains alive
!--------------------------------------------------------------------------------------------------
! subroutine free_all()
! implicit none
!
! type(node), pointer :: item
!
! do
! item => first
!
! if (associated(item) .eqv. .FALSE.) exit
!
! first => first%next
! deallocate(item)
! end do
! end subroutine free_all
subroutine free(this)
implicit none
class(tPartitionedStringList), target, intent(in) :: this
type(tPartitionedStringList), pointer :: new, item
item => this%next
do while (associated(item%next))
new => item
deallocate(item)
item => new%next
enddo
deallocate(item)
end subroutine free
!--------------------------------------------------------------------------------------------------