Skip to content

Commit

Permalink
detect: prepare for SIMD optimizations
Browse files Browse the repository at this point in the history
Make rule group head bitarray 16 bytes aligned and padded to 16 bytes
boundaries to assist SIMD operations in follow up commits.
  • Loading branch information
victorjulien committed Mar 4, 2024
1 parent e7e4305 commit 4ba1f44
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/detect-engine-siggroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4ba1f44

Please sign in to comment.