ZL_Data_commit

Function ZL_Data_commit 

Source
pub unsafe extern "C" fn ZL_Data_commit(
    data: *mut ZL_Data,
    nbElts: usize,
) -> ZL_Report
Expand description

@brief Commit the number of elements written into @p data.

This method must be called exactly once for every output. The @p nbElts must be <= reserved capacity of @p data. Note that, for ZL_Type_string, this is the number of strings written into @p data. The operation will automatically determine the total size of all Strings within @p data.

@returns Success or an error. This function will fail if it is called more than once on the same @p data, or if @p nbElts is greater than @p data’s capacity.

Terminating a Codec without committing anything to @p data (not even 0) is considered an error, that is caught by the Engine (classified as node processing error).

@note @p nbElts, as “number of elements”, is not the same as size in bytes written in the buffer. For Numerics and Structs, the translation is straighforward. For Strings, the field sizes array must be provided first, using ZL_Data_reserveStringLens() to create and access the array. The resulting useful content size will then be calculated from the sum of field sizes. It will be controlled, and there will be an error if sum(sizes) > bufferCapacity.