]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
mpm: in factory register, consider name const
authorVictor Julien <victor@inliniac.net>
Wed, 28 Oct 2015 07:07:28 +0000 (08:07 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 5 Apr 2016 07:37:42 +0000 (09:37 +0200)
src/util-mpm.c
src/util-mpm.h

index 9fbf6c22794ad125ee69f3930cdfd5f2b7d02426..73e13d2260be9acffa9ab485e4865a19165faf75 100644 (file)
@@ -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);
index e8256b4ba5cd8b97a61b12adc3ccab0b75627eed..50a0b8a58648e5afc5e9a3ced0f06ee2ab7b6bfd 100644 (file)
@@ -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;