op_vvec_destroy()
Abstract
Destroys a value vector and releases the memory associated with it.
Syntax
op_vvec_destroy (vvector)
| Argument | Type | Description |
|---|---|---|
vvector |
Vvec_Vector |
value vector to be destroyed |
Return Type
void
No return value.
Example
/* Send some data to an esys interface */
head = op_vvec_remove (vvec, OPC_VVEC_VECTOR_START, 16);
/* Schedule values on the esys vector interface */
op_esys_interface_vector_set (interface_id, op_sim_time(), head, 0);
/* finished with this value vector. */
op_vvec_destroy (head);
Details
After a value vector has been used for the last time, you should deallocate the memory assigned to it by destroying the value vector. Failure to destroy value vectors that will not be use again may result in virtual memory filling up, thereby causing error messages or simulation crashes when the Simulation Kernel tries to allocate memory for new objects.
Purpose
Provide a mechanism to free memory associated with value vectors that are no longer needed. This KP should be invoked after a value vector has been accessed for the last time. Once it returns, the value vector is considered invalid, and therefore it can no longer be referenced or passed to KPs.
Errors
- Recoverable Error: Value vector is invalid.
Reference
- Use the KP op_vvec_create() to create a new vector
- Use the KP op_vvec_copy() to create a new vector consisting of elements removed from another vector