If you need to reassign EVM events after they
are created, received, or read, you must know how an event is held
in memory.
The EvmEvent_t type defines
a pointer to a short handle structure that holds some control information
and a pointer to the event body. When you use EvmEventCreate or any related function to create a new event, the following functions
are performed:
Allocates heap memory
separately for the handle and the event body
Stores the address of
the event body in the handle
Returns the address of
the handle as the function's EvmEvent_t output
argument
You must use the returned pointer any time you
need to refer to the event.
If you modify the event by adding a variable,
for example, it is likely that the space used by the event body may
be freed and reallocated in a new location. If this happens, the address
stored in the handle is automatically updated to reflect the new location.
As a result, the reallocation is completely transparent to your program.
The location of the handle remains unchanged for the life of the event.
If you need to transfer an event from one variable
to another, you can use a simple C-language assignment statement between
variables of type EvmEvent_t. Because the value
you hold is simply a pointer to a constant location — the event's
handle — you can continue to use both of the variables to refer
to the event. However, if you subsequently use EvmEventDestroy to destroy the event, you must discard both references.
Reassigning an event copies only the reference
to its handle; it does not copy the event body. If you need to make
a completely independent copy of the event, use the EvmEventDup function call.