json_destroy Interface

public interface json_destroy

Destructor routine for a json_value pointer. This must be called explicitly if it is no longer needed, before it goes out of scope. Otherwise, a memory leak will result.

Example

Destroy the json_value pointer before the variable goes out of scope:

     subroutine example1()
     type(json_value),pointer :: p
     call json_create_object(p,'')
     call json_add(p,'year',2015)
     call json_print(p)
     call json_destroy(p)
     end subroutine example1

Note: it should NOT be called for a json_value pointer than has already been added to another json_value structure, since doing so may render the other structure invalid. Consider the following example:

     subroutine example2(p)
     type(json_value),pointer,intent(out) :: p
     type(json_value),pointer :: q
     call json_create_object(p,'')
     call json_add(p,'year',2015)
     call json_create_object(q,'q')
     call json_add(q,'val',1)
     call json_add(p, q)  !add q to p structure
     ! do NOT call json_destroy(q) here, because q is
     ! now part of the output structure p.  p should be destroyed
     ! somewhere upstream by the caller of this routine.
     nullify(q) !OK, but not strictly necessary
     end subroutine example2

Calls

interface~~json_destroy~~CallsGraph interface~json_destroy json_destroy proc~json_value_destroy json_value_destroy interface~json_destroy->proc~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

interface~~json_destroy~~CalledByGraph interface~json_destroy json_destroy proc~test_7 test_7 proc~test_7->interface~json_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_10 test_10 proc~test_10->interface~json_destroy 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_7 jf_test_7 program~jf_test_7->proc~test_7 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_10 jf_test_10 program~jf_test_10->proc~test_10 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

Module Procedures

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

Author
Jacob Williams
Date
1/22/2014

Destroy a json_value linked-list structure.