]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: prepare for SIMD optimizations
authorVictor Julien <vjulien@oisf.net>
Mon, 26 Feb 2024 09:52:09 +0000 (10:52 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 4 Mar 2024 10:50:30 +0000 (11:50 +0100)
Make rule group head bitarray 16 bytes aligned and padded to 16 bytes
boundaries to assist SIMD operations in follow up commits.

src/detect-engine-siggroup.c

index 004659b1b192fd0956f2df5290c2807d25074f23..8b783b90e48ad6d43ac4072dfdcefc18e7890b85 100644 (file)
@@ -64,7 +64,7 @@ void SigGroupHeadInitDataFree(SigGroupHeadInitData *sghid)
         sghid->match_array = NULL;
     }
     if (sghid->sig_array != NULL) {
-        SCFree(sghid->sig_array);
+        SCFreeAligned(sghid->sig_array);
         sghid->sig_array = NULL;
     }
     if (sghid->app_mpms != NULL) {
@@ -92,9 +92,12 @@ static SigGroupHeadInitData *SigGroupHeadInitDataAlloc(uint32_t size)
         return NULL;
 
     /* initialize the signature bitarray */
-    sghid->sig_size = size;
-    if ((sghid->sig_array = SCCalloc(1, sghid->sig_size)) == NULL)
+    size = sghid->sig_size = size + 16 - (size % 16);
+    void *ptr = SCMallocAligned(sghid->sig_size, 16);
+    if (ptr == NULL)
         goto error;
+    memset(ptr, 0, size);
+    sghid->sig_array = ptr;
 
     return sghid;
 error: