json_value_destroy Subroutine

private recursivesubroutine json_value_destroy(me, destroy_next)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
logical(kind=LK), intent(in), optional :: destroy_next

if true, then me%next is also destroyed (default is true)

Description

Destroy a json_value linked-list structure.

Calls

proc~~json_value_destroy~~CallsGraph proc~json_value_destroy json_value_destroy proc~json_value_destroy->proc~json_value_destroy proc~destroy_json_data destroy_json_data proc~json_value_destroy->proc~destroy_json_data
Help

Called By

proc~~json_value_destroy~~CalledByGraph proc~json_value_destroy json_value_destroy proc~json_value_destroy->proc~json_value_destroy proc~json_file_destroy json_file_destroy proc~json_file_destroy->proc~json_value_destroy proc~json_value_remove json_value_remove proc~json_value_remove->proc~json_value_destroy interface~json_remove json_remove interface~json_remove->proc~json_value_remove proc~test_1 test_1 proc~test_1->interface~json_remove proc~json_value_remove_if_present json_value_remove_if_present proc~json_value_remove_if_present->interface~json_remove proc~test_7 test_7 proc~test_7->interface~json_remove interface~json_destroy json_destroy proc~test_7->interface~json_destroy program~jf_test_1 jf_test_1 program~jf_test_1->proc~test_1 proc~wrap_json_value_remove_if_present wrap_json_value_remove_if_present proc~wrap_json_value_remove_if_present->proc~json_value_remove_if_present interface~json_remove_if_present json_remove_if_present interface~json_remove_if_present->proc~json_value_remove_if_present proc~test_10 test_10 proc~test_10->interface~json_remove_if_present proc~test_10->interface~json_destroy program~jf_test_10 jf_test_10 program~jf_test_10->proc~test_10 program~jf_test_7 jf_test_7 program~jf_test_7->proc~test_7 interface~json_destroy->proc~json_value_destroy proc~test_2 test_2 proc~test_2->interface~json_destroy proc~parse_array parse_array proc~parse_array->interface~json_destroy proc~parse_value parse_value proc~parse_array->proc~parse_value proc~test_8 test_8 proc~test_8->interface~json_destroy interface~json_parse json_parse proc~test_8->interface~json_parse proc~test_14 test_14 proc~test_14->interface~json_destroy proc~test_14->interface~json_parse proc~parse_object parse_object proc~parse_object->interface~json_destroy proc~parse_object->proc~parse_object proc~parse_object->proc~parse_value proc~test_4 test_4 proc~test_4->interface~json_destroy program~jf_test_2 jf_test_2 program~jf_test_2->proc~test_2 proc~parse_value->proc~parse_array proc~parse_value->proc~parse_object proc~json_parse_string json_parse_string proc~json_parse_string->proc~parse_value proc~json_parse_file json_parse_file proc~json_parse_file->proc~parse_value proc~wrap_json_parse_string wrap_json_parse_string proc~wrap_json_parse_string->proc~json_parse_string interface~json_parse->proc~json_parse_string interface~json_parse->proc~json_parse_file proc~json_file_load json_file_load proc~json_file_load->interface~json_parse proc~json_file_load_from_string json_file_load_from_string proc~json_file_load_from_string->interface~json_parse proc~wrap_json_file_load_from_string wrap_json_file_load_from_string proc~wrap_json_file_load_from_string->proc~json_file_load_from_string program~jf_test_8 jf_test_8 program~jf_test_8->proc~test_8 program~jf_test_14 jf_test_14 program~jf_test_14->proc~test_14 program~jf_test_4 jf_test_4 program~jf_test_4->proc~test_4
Help

Variables

TypeVisibility AttributesNameInitial
logical(kind=LK), public :: des_next
type(json_value), public, pointer:: p

Source Code

    recursive subroutine json_value_destroy(me,destroy_next)

    implicit none

    type(json_value),pointer :: me
    logical(LK),intent(in),optional :: destroy_next  !! if true, then me%next is also destroyed (default is true)

    logical(LK) :: des_next
    type(json_value), pointer :: p

    if (associated(me)) then

        if (present(destroy_next)) then
            des_next = destroy_next
        else
            des_next = .true.
        end if

        if (allocated(me%name)) deallocate(me%name)

        call destroy_json_data(me)

        if (associated(me%children)) then
            do while (me%n_children > 0)
                p => me%children
                me%children => me%children%next
                me%n_children = me%n_children - 1
                call json_value_destroy(p,.false.)
            end do
            nullify(me%children)
            nullify(p)
        end if

        if (associated(me%next) .and. des_next) call json_value_destroy(me%next)

        if (associated(me%previous)) nullify(me%previous)
        if (associated(me%parent))   nullify(me%parent)
        if (associated(me%tail))     nullify(me%tail)

        deallocate(me)

        nullify(me)

    end if

    end subroutine json_value_destroy