json_file_destroy Subroutine

private subroutine json_file_destroy(me, destroy_core)

Destroy the json_value data in a json_file. This may be done when the variable is no longer needed, or will be reused to open a different file. Otherwise a memory leak will occur.

Optionally, also destroy the json_core instance (this is not necessary to prevent memory leaks, since a json_core does not use pointers).

See also

History

  • 12/9/2013 : Created
  • 4/26/2016 : Added optional destroy_core argument

Note

This routine will be called automatically when the variable goes out of scope.

Type Bound

json_file

Arguments

Type IntentOptional Attributes Name
class(json_file), intent(inout) :: me
logical, intent(in), optional :: destroy_core

to also destroy the json_core. default is to leave it as is.


Calls

proc~~json_file_destroy~~CallsGraph proc~json_file_destroy json_file%json_file_destroy none~destroy json_core%destroy proc~json_file_destroy->none~destroy proc~destroy_json_core json_core%destroy_json_core none~destroy->proc~destroy_json_core proc~json_value_destroy json_core%json_value_destroy none~destroy->proc~json_value_destroy proc~json_value_destroy->none~destroy proc~destroy_json_data destroy_json_data proc~json_value_destroy->proc~destroy_json_data

Called by

proc~~json_file_destroy~~CalledByGraph proc~json_file_destroy json_file%json_file_destroy 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~2 json_file%deserialize proc~assign_string_to_json_file->none~deserialize~2 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~2->proc~json_file_load_from_string proc~wrap_json_file_load_from_string json_file%wrap_json_file_load_from_string none~deserialize~2->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~2 proc~initialize_json_file_from_string_v2 initialize_json_file_from_string_v2 proc~initialize_json_file_from_string_v2->none~deserialize~2 proc~wrap_json_file_load_from_string->none~deserialize~2 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 json_file_destroy(me,destroy_core)

    implicit none

    class(json_file),intent(inout) :: me
    logical,intent(in),optional :: destroy_core  !! to also destroy the [[json_core(type)]].
                                                 !! default is to leave it as is.

    if (associated(me%p)) call me%core%destroy(me%p)

    if (present(destroy_core)) then
        if (destroy_core) call me%core%destroy()
    end if

    end subroutine json_file_destroy