Function hyperscan_sys::hs_close_stream
source · [−]pub unsafe extern "C" fn hs_close_stream(
id: *mut hs_stream_t,
scratch: *mut hs_scratch_t,
onEvent: match_event_handler,
ctxt: *mut c_void
) -> hs_error_t
Expand description
Close a stream.
This function completes matching on the given stream and frees the memory associated with the stream state. After this call, the stream pointed to by @p id is invalid and can no longer be used. To reuse the stream state after completion, rather than closing it, the @ref hs_reset_stream function can be used.
This function must be called for any stream created with @ref hs_open_stream(), even if scanning has been terminated by a non-zero return from the match callback function.
Note: This operation may result in matches being returned (via calls to the
match event callback) for expressions anchored to the end of the data stream
(for example, via the use of the $
meta-character). If these matches are
not desired, NULL may be provided as the @ref match_event_handler callback.
If NULL is provided as the @ref match_event_handler callback, it is permissible to provide a NULL scratch.
@param id The stream ID returned by @ref hs_open_stream().
@param scratch A per-thread scratch space allocated by @ref hs_alloc_scratch(). This is allowed to be NULL only if the @p onEvent callback is also NULL.
@param onEvent Pointer to a match event callback function. If a NULL pointer is given, no matches will be returned.
@param ctxt The user defined pointer which will be passed to the callback function when a match occurs.
@return Returns @ref HS_SUCCESS on success, other values on failure.