Function mupdf_sys::fz_pack_path

source ·
pub unsafe extern "C" fn fz_pack_path(
    ctx: *mut fz_context,
    pack: *mut u8,
    max: usize,
    path: *const fz_path
) -> usize
Expand description

Pack a path into the given block. To minimise the size of paths, this function allows them to be packed into a buffer with other information. Paths can be used interchangeably regardless of how they are packed.

pack: Pointer to a block of data to pack the path into. Should be aligned by the caller to the same alignment as required for a fz_path pointer.

max: The number of bytes available in the block. If max < sizeof(fz_path) then an exception will be thrown. If max >= the value returned by fz_packed_path_size, then this call will never fail, except in low memory situations with large paths.

path: The path to pack.

Returns the number of bytes within the block used. Callers can access the packed path data by casting the value of pack on entry to be a fz_path *.

Throws exceptions on failure to allocate, or if max < sizeof(fz_path).

Implementation details: Paths can be ‘unpacked’, ‘flat’, or ‘open’. Standard paths, as created are ‘unpacked’. Paths that will pack into less than max bytes will be packed as ‘flat’, unless they are too large (where large indicates that they exceed some private implementation defined limits, currently including having more than 256 coordinates or commands).

Large paths are ‘open’ packed as a header into the given block, plus pointers to other data blocks.

Users should not have to care about whether paths are ‘open’ or ‘flat’ packed. Simply pack a path (if required), and then forget about the details.