mpm: in factory register, consider name const

pull/1980/head
Victor Julien 11 years ago
parent 2b84387ea4
commit 4e91f6b1e6

@ -72,11 +72,7 @@ int32_t MpmFactoryRegisterMpmCtxProfile(DetectEngineCtx *de_ctx, const char *nam
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
item[0].name = SCStrdup(name); item[0].name = name;
if (item[0].name == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
/* toserver */ /* toserver */
item[0].mpm_ctx_ts = SCMalloc(sizeof(MpmCtx)); 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; de_ctx->mpm_ctx_factory_container->items = items;
MpmCtxFactoryItem *new_item = &items[de_ctx->mpm_ctx_factory_container->no_of_items]; MpmCtxFactoryItem *new_item = &items[de_ctx->mpm_ctx_factory_container->no_of_items];
new_item[0].name = SCStrdup(name); new_item[0].name = name;
if (new_item[0].name == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
/* toserver */ /* toserver */
new_item[0].mpm_ctx_ts = SCMalloc(sizeof(MpmCtx)); new_item[0].mpm_ctx_ts = SCMalloc(sizeof(MpmCtx));
@ -249,8 +241,6 @@ void MpmFactoryDeRegisterAllMpmCtxProfiles(DetectEngineCtx *de_ctx)
int i = 0; int i = 0;
MpmCtxFactoryItem *items = de_ctx->mpm_ctx_factory_container->items; MpmCtxFactoryItem *items = de_ctx->mpm_ctx_factory_container->items;
for (i = 0; i < de_ctx->mpm_ctx_factory_container->no_of_items; i++) { 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 != NULL) {
if (items[i].mpm_ctx_ts->mpm_type != MPM_NOTSET) 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); mpm_table[items[i].mpm_ctx_ts->mpm_type].DestroyCtx(items[i].mpm_ctx_ts);

@ -128,7 +128,7 @@ typedef struct MpmCtx_ {
#define MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD 0x01 #define MPM_CTX_FACTORY_FLAGS_PREPARE_WITH_SIG_GROUP_BUILD 0x01
typedef struct MpmCtxFactoryItem_ { typedef struct MpmCtxFactoryItem_ {
char *name; const char *name;
MpmCtx *mpm_ctx_ts; MpmCtx *mpm_ctx_ts;
MpmCtx *mpm_ctx_tc; MpmCtx *mpm_ctx_tc;
int32_t id; int32_t id;

Loading…
Cancel
Save