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