mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 19:24:25 +03:00
scratch: don't leave in use after hs_clone_scratch
Also updated unit tests to always check hs_alloc_scratch()'s return value.
This commit is contained in:
committed by
Matthew Barr
parent
6c1143a264
commit
73610c0b64
@@ -129,7 +129,7 @@ hs_error_t alloc_scratch(const hs_scratch_t *proto, hs_scratch_t **scratch) {
|
||||
*s = *proto;
|
||||
|
||||
s->magic = SCRATCH_MAGIC;
|
||||
s->in_use = 1;
|
||||
s->in_use = 0;
|
||||
s->scratchSize = alloc_size;
|
||||
s->scratch_alloc = (char *)s_tmp;
|
||||
|
||||
@@ -357,9 +357,10 @@ hs_error_t hs_alloc_scratch(const hs_database_t *db, hs_scratch_t **scratch) {
|
||||
}
|
||||
} else {
|
||||
hs_scratch_free(proto_tmp); /* kill off temp used for sizing */
|
||||
unmarkScratchInUse(*scratch);
|
||||
}
|
||||
|
||||
unmarkScratchInUse(*scratch);
|
||||
assert(!(*scratch)->in_use);
|
||||
return HS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -376,6 +377,7 @@ hs_error_t hs_clone_scratch(const hs_scratch_t *src, hs_scratch_t **dest) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
assert(!(*dest)->in_use);
|
||||
return HS_SUCCESS;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user