mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-30 03:34:25 +03:00
Allow no scratch for stream reset API calls
Bring hs_reset_stream(), hs_reset_and_copy_stream()'s functionality into line with hs_close_stream() by accepting a NULL scratch if and only if the match callback is also NULL, indicating that no matches should be delivered.
This commit is contained in:
committed by
Matthew Barr
parent
b59491d0db
commit
9ff1303cd8
@@ -250,7 +250,8 @@ hs_error_t hs_close_stream(hs_stream_t *id, hs_scratch_t *scratch,
|
||||
* for future use and is unused at present.
|
||||
*
|
||||
* @param scratch
|
||||
* A per-thread scratch space allocated by @ref hs_alloc_scratch().
|
||||
* A per-thread scratch space allocated by @ref hs_alloc_scratch(). This is
|
||||
* allowed to be NULL only if the @a onEvent callback is also NULL.
|
||||
*
|
||||
* @param onEvent
|
||||
* Pointer to a match event callback function. If a NULL pointer is given,
|
||||
@@ -299,7 +300,8 @@ hs_error_t hs_copy_stream(hs_stream_t **to_id, const hs_stream_t *from_id);
|
||||
* The stream (as created by @ref hs_open_stream()) to be copied.
|
||||
*
|
||||
* @param scratch
|
||||
* A per-thread scratch space allocated by @ref hs_alloc_scratch().
|
||||
* A per-thread scratch space allocated by @ref hs_alloc_scratch(). This is
|
||||
* allowed to be NULL only if the @a onEvent callback is also NULL.
|
||||
*
|
||||
* @param onEvent
|
||||
* Pointer to a match event callback function. If a NULL pointer is given,
|
||||
|
@@ -1163,11 +1163,10 @@ hs_error_t hs_reset_and_copy_stream(hs_stream_t *to_id,
|
||||
return HS_INVALID;
|
||||
}
|
||||
|
||||
if (!scratch || !validScratch(to_id->rose, scratch)) {
|
||||
return HS_INVALID;
|
||||
}
|
||||
|
||||
if (onEvent) {
|
||||
if (!scratch || !validScratch(to_id->rose, scratch)) {
|
||||
return HS_INVALID;
|
||||
}
|
||||
report_eod_matches(to_id, scratch, onEvent, context);
|
||||
}
|
||||
|
||||
@@ -1406,12 +1405,14 @@ HS_PUBLIC_API
|
||||
hs_error_t hs_reset_stream(hs_stream_t *id, UNUSED unsigned int flags,
|
||||
hs_scratch_t *scratch, match_event_handler onEvent,
|
||||
void *context) {
|
||||
if (!id || !scratch || !validScratch(id->rose, scratch)) {
|
||||
if (!id) {
|
||||
return HS_INVALID;
|
||||
}
|
||||
|
||||
/* user wants eod matches */
|
||||
if (onEvent) {
|
||||
if (!scratch || !validScratch(id->rose, scratch)) {
|
||||
return HS_INVALID;
|
||||
}
|
||||
report_eod_matches(id, scratch, onEvent, context);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user