|
|
|
@ -76,7 +76,7 @@ void BoyerMooreCtxToNocase(BmCtx *bm_ctx, uint8_t *needle, uint16_t needle_len)
|
|
|
|
|
*/
|
|
|
|
|
BmCtx *BoyerMooreCtxInit(const uint8_t *needle, uint16_t needle_len)
|
|
|
|
|
{
|
|
|
|
|
BmCtx *new = SCMalloc(sizeof(BmCtx));
|
|
|
|
|
BmCtx *new = SCMalloc(sizeof(BmCtx) + sizeof(uint16_t) * (needle_len + 1));
|
|
|
|
|
if (unlikely(new == NULL)) {
|
|
|
|
|
SCLogError(SC_ERR_FATAL, "Fatal error encountered in BoyerMooreCtxInit. Exiting...");
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
@ -85,11 +85,6 @@ BmCtx *BoyerMooreCtxInit(const uint8_t *needle, uint16_t needle_len)
|
|
|
|
|
/* Prepare bad chars */
|
|
|
|
|
PreBmBc(needle, needle_len, new->bmBc);
|
|
|
|
|
|
|
|
|
|
new->bmGs = SCMalloc(sizeof(uint16_t) * (needle_len + 1));
|
|
|
|
|
if (new->bmGs == NULL) {
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Prepare good Suffixes */
|
|
|
|
|
if (PreBmGs(needle, needle_len, new->bmGs) == -1) {
|
|
|
|
|
SCLogError(SC_ERR_FATAL, "Fatal error encountered in BooyerMooreCtxInit. Exiting...");
|
|
|
|
@ -128,9 +123,6 @@ void BoyerMooreCtxDeInit(BmCtx *bmctx)
|
|
|
|
|
if (bmctx == NULL)
|
|
|
|
|
SCReturn;
|
|
|
|
|
|
|
|
|
|
if (bmctx->bmGs != NULL)
|
|
|
|
|
SCFree(bmctx->bmGs);
|
|
|
|
|
|
|
|
|
|
SCFree(bmctx);
|
|
|
|
|
|
|
|
|
|
SCReturn;
|
|
|
|
|