Function hyperscan_sys::hs_alloc_scratch
source · [−]pub unsafe extern "C" fn hs_alloc_scratch(
db: *const hs_database_t,
scratch: *mut *mut hs_scratch_t
) -> hs_error_t
Expand description
Allocate a “scratch” space for use by Hyperscan.
This is required for runtime use, and one scratch space per thread, or concurrent caller, is required. Any allocator callback set by @ref hs_set_scratch_allocator() or @ref hs_set_allocator() will be used by this function.
@param db The database, as produced by @ref hs_compile().
@param scratch On first allocation, a pointer to NULL should be provided so a new scratch can be allocated. If a scratch block has been previously allocated, then a pointer to it should be passed back in to see if it is valid for this database block. If a new scratch block is required, the original will be freed and the new one returned, otherwise the previous scratch block will be returned. On success, the scratch block will be suitable for use with the provided database in addition to any databases that original scratch space was suitable for.
@return @ref HS_SUCCESS on successful allocation; @ref HS_NOMEM if the allocation fails. Other errors may be returned if invalid parameters are specified.