From: Victor Julien Date: Wed, 28 Oct 2015 07:07:28 +0000 (+0100) Subject: mpm: in factory register, consider name const X-Git-Tag: suricata-3.1RC1~314 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e91f6b1e65a6a46fbb88dcc411508790a97a801;p=thirdparty%2Fsuricata.git mpm: in factory register, consider name const --- diff --git a/src/util-mpm.c b/src/util-mpm.c index 9fbf6c2279..73e13d2260 100644 --- a/src/util-mpm.c +++ b/src/util-mpm.c @@ -72,11 +72,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam exit(EXIT_FAILURE); } - item[0].name = SCStrdup(name); - if (item[0].name == NULL) { - SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); - exit(EXIT_FAILURE); - } + item[0].name = name; /* toserver */ item[0].mpm_ctx_ts = SCMalloc(sizeof(MpmCtx)); @@ -152,11 +148,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam de_ctx->mpm_ctx_factory_container->items = items; MpmCtxFactoryItem *new_item = &items[de_ctx->mpm_ctx_factory_container->no_of_items]; - new_item[0].name = SCStrdup(name); - if (new_item[0].name == NULL) { - SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); - exit(EXIT_FAILURE); - } + new_item[0].name = name; /* toserver */ new_item[0].mpm_ctx_ts = SCMalloc(sizeof(MpmCtx)); @@ -249,8 +241,6 @@ void MpmFactoryDeRegisterAllMpmCtxProfiles(DetectEngineCtx *de_ctx) int i = 0; MpmCtxFactoryItem *items = de_ctx->mpm_ctx_factory_container->items; for (i = 0; i < de_ctx->mpm_ctx_factory_container->no_of_items; i++) { - if (items[i].name != NULL) - SCFree(items[i].name); if (items[i].mpm_ctx_ts != NULL) { if (items[i].mpm_ctx_ts->mpm_type != MPM_NOTSET) mpm_table[items[i].mpm_ctx_ts->mpm_type].DestroyCtx(items[i].mpm_ctx_ts); diff --git a/src/util-mpm.h b/src/util-mpm.h index e8256b4ba5..50a0b8a586 100644 --- a/src/util-mpm.h +++ b/src/util-mpm.h @@ -128,7 +128,7 @@ typedef struct MpmCtx_ { #define MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD 0x01 typedef struct MpmCtxFactoryItem_ { - char *name; + const char *name; MpmCtx *mpm_ctx_ts; MpmCtx *mpm_ctx_tc; int32_t id;