mirror of https://github.com/status-im/evmc.git
EVM-C: Clarify docs about result context and releasing
This commit is contained in:
parent
7c79af5d59
commit
6b94734d1a
|
@ -83,7 +83,7 @@ static struct evm_result evm_execute(struct evm_instance* instance,
|
||||||
ret.output_data = output_data;
|
ret.output_data = output_data;
|
||||||
ret.output_size = address_size;
|
ret.output_size = address_size;
|
||||||
ret.release = &free_result_output_data;
|
ret.release = &free_result_output_data;
|
||||||
ret.internal_memory = NULL; // We don't need another pointer.
|
ret.context = NULL; // We don't need another pointer.
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,20 +106,33 @@ struct evm_result {
|
||||||
/// The size of the output data.
|
/// The size of the output data.
|
||||||
size_t output_size;
|
size_t output_size;
|
||||||
|
|
||||||
/// The pointer to the result release implementation.
|
/// The pointer to a function releasing all resources associated with
|
||||||
|
/// the result object.
|
||||||
///
|
///
|
||||||
/// This function pointer may be set by the EVM implementation and must be
|
/// This function pointer is optional (MAY be NULL) and MAY be set by
|
||||||
/// used by the user to release memory associated with the result object.
|
/// the EVM implementation. If set it MUST be used by the user to
|
||||||
/// In case it is NULL the user does not have to release any resources.
|
/// release memory and other resources associated with the result object.
|
||||||
|
/// After the result resources are released the result object
|
||||||
|
/// MUST NOT be used any more.
|
||||||
|
///
|
||||||
|
/// The suggested code pattern for releasing EVM results:
|
||||||
|
/// @code
|
||||||
|
/// struct evm_result result = ...;
|
||||||
|
/// if (result.release)
|
||||||
|
/// result.release(&result);
|
||||||
|
/// @endcode
|
||||||
///
|
///
|
||||||
/// @note
|
/// @note
|
||||||
/// It works similarly to C++ virtual destructor. Attaching the release
|
/// It works similarly to C++ virtual destructor. Attaching the release
|
||||||
/// function to the result itself allows EVM composition.
|
/// function to the result itself allows EVM composition.
|
||||||
evm_release_result_fn release;
|
evm_release_result_fn release;
|
||||||
|
|
||||||
/// The pointer to EVM-owned memory. For EVM internal use.
|
/// The optional pointer to an internal EVM context.
|
||||||
/// @see output_data.
|
///
|
||||||
void* internal_memory;
|
/// This field MAY be used by _EVM implementations_ to store additional
|
||||||
|
/// result context (e.g. memory buffers). The pointer value MUST NOT
|
||||||
|
/// be accessed nor changed by EVM users.
|
||||||
|
void* context;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The query callback key.
|
/// The query callback key.
|
||||||
|
|
Loading…
Reference in New Issue