Can I free the structure pointer that I set in a packet field after calling the kernel procedure op_pk_nfd_set ()?
Can I free the structure pointer that I set in a packet field after calling the kernel procedure op_pk_nfd_set ()?
No, the structure pointer should not be freed by user code after being set in a packet field. After the call to op_pk_nfd_set() on a Structure packet field, the structure pointer will be owned by the packet and the Simulation Kernel is responsible for deallocating it when the packet is destroyed. However, if you later get the structure from the packet using op_pk_nfd_get(), then you are responsible for deallocating the structure---or for setting it back on the packet.When packets with structure fields are copied, the structures are copied using the copy_proc and alloc_size arguments that were provided with the op_pk_nfd_set() call. This means that the structure pointer in a copy of the original packet will not point to the same structure object (the copied packet and the original packet will not have the pointer values for the structure). Destroying such a copy packet will not harm any other copy of the packet (there is no danger of double-deallocation of structures). For additional information, please search in the online FAQs for structure. Also, please read in the online documentation Simulation Kernel -> Packet Package -> Named Field Sub-Package -> op_pk_nfd_set_ptr (). Note that the older, deprecated version of this function, op_pk_nfd_set (), is documented for the 3 possible formats of op_pk_nfd_set (). Be sure to read the version used for structure fields.
DES Kernel->Process Modeling/Coding