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~3 json_core%destroy proc~json_file_destroy->none~destroy~3 proc~destroy_json_core json_core%destroy_json_core none~destroy~3->proc~destroy_json_core proc~json_value_destroy json_core%json_value_destroy none~destroy~3->proc~json_value_destroy proc~json_value_destroy->none~destroy~3 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 proc~finalize_json_file finalize_json_file proc~finalize_json_file->proc~json_file_destroy proc~wrap_assign_string_to_json_file wrap_assign_string_to_json_file proc~wrap_assign_string_to_json_file->proc~assign_string_to_json_file

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