From: Victor Julien Date: Mon, 26 Feb 2024 09:52:09 +0000 (+0100) Subject: detect: prepare for SIMD optimizations X-Git-Tag: suricata-7.0.6~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14e8c5582793d5a48abcff5306d29e57a440825e;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. (cherry picked from commit 4ba1f44e0d882ffb6d7d93b2864c9dd405f78ea5) --- diff --git a/src/detect-engine-siggroup.c b/src/detect-engine-siggroup.c index c05b6c3daa..dde000b49a 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) { @@ -94,9 +94,12 @@ static SigGroupHeadInitData *SigGroupHeadInitDataAlloc(uint32_t size) memset(sghid, 0x00, sizeof(SigGroupHeadInitData)); /* initialize the signature bitarray */ - sghid->sig_size = size; - if ( (sghid->sig_array = SCMalloc(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; memset(sghid->sig_array, 0, sghid->sig_size);