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:
Justin Viiret
2016-05-09 09:29:44 +10:00
committed by Matthew Barr
parent 6c1143a264
commit 73610c0b64
12 changed files with 293 additions and 151 deletions

View File

@@ -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;
}