hash_table_destroy Subroutine

private subroutine hash_table_destroy(me)

Destroy hash table and free all memory

Type Bound

json_hash_table

Arguments

Type IntentOptional Attributes Name
class(json_hash_table), intent(inout) :: me

Calls

proc~~hash_table_destroy~~CallsGraph proc~hash_table_destroy json_hash_table%hash_table_destroy none~destroy~4 json_core%destroy proc~hash_table_destroy->none~destroy~4 proc~destroy_json_core json_core%destroy_json_core none~destroy~4->proc~destroy_json_core proc~json_value_destroy json_core%json_value_destroy none~destroy~4->proc~json_value_destroy proc~json_value_destroy->none~destroy~4 proc~destroy_json_data destroy_json_data proc~json_value_destroy->proc~destroy_json_data

Called by

proc~~hash_table_destroy~~CalledByGraph proc~hash_table_destroy json_hash_table%hash_table_destroy proc~destroy_hash json_file%destroy_hash proc~destroy_hash->proc~hash_table_destroy proc~hash_table_finalize hash_table_finalize proc~hash_table_finalize->proc~hash_table_destroy proc~json_file_destroy json_file%json_file_destroy proc~json_file_destroy->proc~destroy_hash proc~assign_string_to_json_file json_file%assign_string_to_json_file proc~assign_string_to_json_file->proc~json_file_destroy none~deserialize json_file%deserialize proc~assign_string_to_json_file->none~deserialize proc~finalize_json_file finalize_json_file proc~finalize_json_file->proc~json_file_destroy proc~json_file_add json_file%json_file_add proc~json_file_add->proc~json_file_destroy proc~json_file_load json_file%json_file_load proc~json_file_load->proc~json_file_destroy proc~json_file_load_from_string json_file%json_file_load_from_string proc~json_file_load_from_string->proc~json_file_destroy none~deserialize->proc~json_file_load_from_string proc~wrap_json_file_load_from_string json_file%wrap_json_file_load_from_string none~deserialize->proc~wrap_json_file_load_from_string proc~wrap_assign_string_to_json_file json_file%wrap_assign_string_to_json_file proc~wrap_assign_string_to_json_file->proc~assign_string_to_json_file proc~initialize_json_file_from_string initialize_json_file_from_string proc~initialize_json_file_from_string->none~deserialize proc~initialize_json_file_from_string_v2 initialize_json_file_from_string_v2 proc~initialize_json_file_from_string_v2->none~deserialize proc~wrap_json_file_load_from_string->none~deserialize interface~json_file json_file interface~json_file->proc~initialize_json_file_from_string interface~json_file->proc~initialize_json_file_from_string_v2 proc~wrap_initialize_json_file_from_string wrap_initialize_json_file_from_string interface~json_file->proc~wrap_initialize_json_file_from_string proc~wrap_initialize_json_file_from_string_v2 wrap_initialize_json_file_from_string_v2 interface~json_file->proc~wrap_initialize_json_file_from_string_v2 proc~wrap_initialize_json_file_from_string->proc~initialize_json_file_from_string proc~wrap_initialize_json_file_from_string_v2->proc~initialize_json_file_from_string_v2

Source Code

    subroutine hash_table_destroy(me)

    class(json_hash_table), intent(inout) :: me

    integer(IK) :: i !! counter
    type(hash_node_t), pointer :: current, temp

    if (.not. allocated(me%buckets)) return

    ! Free all linked lists
    do i = 0, me%capacity - 1
        current => me%buckets(i)%next
        do while (associated(current))
            temp => current
            current => current%next
            if (allocated(temp%key)) deallocate(temp%key)
            deallocate(temp)
        end do
    end do

    deallocate(me%buckets)
    me%size = 0_IK

    ! also destroy the JSON core instance
    call me%json%destroy()

    end subroutine hash_table_destroy