From: Victor Julien Date: Mon, 26 Feb 2024 09:52:09 +0000 (+0100) Subject: detect: prepare for SIMD optimizations X-Git-Tag: suricata-8.0.0-beta1~1674 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ba1f44e0d882ffb6d7d93b2864c9dd405f78ea5;p=thirdparty%2Fsuricata.git detect: prepare for SIMD optimizations Make rule group head bitarray 16 bytes aligned and padded to 16 bytes boundaries to assist SIMD operations in follow up commits. --- diff --git a/src/detect-engine-siggroup.c b/src/detect-engine-siggroup.c index 004659b1b1..8b783b90e4 100644 --- a/src/detect-engine-siggroup.c +++ b/src/detect-engine-siggroup.c @@ -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: