When using zero-copy write APIs (tpa_write or tpa_zwritev), the application must not free the write buffer immediately after the API returns. Because libtpa uses the buffer for potential retransmissions, the buffer remains referenced by the library until the data is acknowledged (ACKed) by the remote end.
To safely free the buffer, you must provide a callback function in the tpa_iovec structure using the iov_write_done field. Libtpa will invoke this callback once the data is no longer needed.
/* Example concept: the callback is triggered when data is ACKed */
struct tpa_iovec iov;
iov.iov_write_done = my_write_done_callback;
iov.iov_param = my_context;
tpa_zwritev(..., &iov, ...);