|
|
|
|
@ -2316,6 +2316,7 @@ void WmDestroyCtx(MpmCtx *mpm_ctx) {
|
|
|
|
|
void WmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t matchsize) {
|
|
|
|
|
memset(mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
|
|
|
|
|
|
|
|
|
|
if (sizeof(WmThreadCtx) > 0) { /* size can be 0 when optimized */
|
|
|
|
|
mpm_thread_ctx->ctx = malloc(sizeof(WmThreadCtx));
|
|
|
|
|
if (mpm_thread_ctx->ctx == NULL)
|
|
|
|
|
return;
|
|
|
|
|
@ -2324,6 +2325,7 @@ void WmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t mat
|
|
|
|
|
|
|
|
|
|
mpm_thread_ctx->memory_cnt++;
|
|
|
|
|
mpm_thread_ctx->memory_size += sizeof(WmThreadCtx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* alloc an array with the size of _all_ keys in all instances.
|
|
|
|
|
* this is done so the detect engine won't have to care about
|
|
|
|
|
@ -2347,16 +2349,16 @@ void WmThreadInitCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, uint32_t mat
|
|
|
|
|
|
|
|
|
|
void WmThreadDestroyCtx(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx) {
|
|
|
|
|
WmThreadCtx *ctx = (WmThreadCtx *)mpm_thread_ctx->ctx;
|
|
|
|
|
if (ctx) {
|
|
|
|
|
if (mpm_thread_ctx->match != NULL) {
|
|
|
|
|
if (ctx != NULL) { /* size can be 0 when optimized */
|
|
|
|
|
mpm_thread_ctx->memory_cnt--;
|
|
|
|
|
mpm_thread_ctx->memory_size -= ((mpm_thread_ctx->matchsize + 1) * sizeof(MpmMatchBucket));
|
|
|
|
|
free(mpm_thread_ctx->match);
|
|
|
|
|
mpm_thread_ctx->memory_size -= sizeof(WmThreadCtx);
|
|
|
|
|
free(mpm_thread_ctx->ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mpm_thread_ctx->match != NULL) {
|
|
|
|
|
mpm_thread_ctx->memory_cnt--;
|
|
|
|
|
mpm_thread_ctx->memory_size -= sizeof(WmThreadCtx);
|
|
|
|
|
free(mpm_thread_ctx->ctx);
|
|
|
|
|
mpm_thread_ctx->memory_size -= ((mpm_thread_ctx->matchsize + 1) * sizeof(MpmMatchBucket));
|
|
|
|
|
free(mpm_thread_ctx->match);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MpmMatchFreeSpares(mpm_thread_ctx, mpm_thread_ctx->sparelist);
|
|
|
|
|
@ -2410,6 +2412,7 @@ int WmTestInitCtx03 (void) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int WmTestThreadInitCtx01 (void) {
|
|
|
|
|
if (sizeof(WmThreadCtx) > 0) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
MpmCtx mpm_ctx;
|
|
|
|
|
memset(&mpm_ctx, 0x00, sizeof(MpmCtx));
|
|
|
|
|
@ -2424,6 +2427,9 @@ int WmTestThreadInitCtx01 (void) {
|
|
|
|
|
WmThreadDestroyCtx(&mpm_ctx, &mpm_thread_ctx);
|
|
|
|
|
WmDestroyCtx(&mpm_ctx);
|
|
|
|
|
return result;
|
|
|
|
|
} else {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int WmTestThreadInitCtx02 (void) {
|
|
|
|
|
|