From: Victor Julien Date: Fri, 24 Nov 2023 18:28:37 +0000 (+0100) Subject: flow/storage: use flex array instead of calculated ptr X-Git-Tag: suricata-8.0.0-beta1~2027 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d405efd3f67704209186c5def93846610ff91726;p=thirdparty%2Fsuricata.git flow/storage: use flex array instead of calculated ptr --- diff --git a/src/flow-storage.c b/src/flow-storage.c index 1ce9c07948..53b67ba630 100644 --- a/src/flow-storage.c +++ b/src/flow-storage.c @@ -39,28 +39,28 @@ unsigned int FlowStorageSize(void) void *FlowGetStorageById(const Flow *f, FlowStorageId id) { - return StorageGetById((Storage *)((void *)f + sizeof(Flow)), STORAGE_FLOW, id.id); + return StorageGetById(f->storage, STORAGE_FLOW, id.id); } int FlowSetStorageById(Flow *f, FlowStorageId id, void *ptr) { - return StorageSetById((Storage *)((void *)f + sizeof(Flow)), STORAGE_FLOW, id.id, ptr); + return StorageSetById(f->storage, STORAGE_FLOW, id.id, ptr); } void *FlowAllocStorageById(Flow *f, FlowStorageId id) { - return StorageAllocByIdPrealloc((Storage *)((void *)f + sizeof(Flow)), STORAGE_FLOW, id.id); + return StorageAllocByIdPrealloc(f->storage, STORAGE_FLOW, id.id); } void FlowFreeStorageById(Flow *f, FlowStorageId id) { - StorageFreeById((Storage *)((void *)f + sizeof(Flow)), STORAGE_FLOW, id.id); + StorageFreeById(f->storage, STORAGE_FLOW, id.id); } void FlowFreeStorage(Flow *f) { if (FlowStorageSize() > 0) - StorageFreeAll((Storage *)((void *)f + sizeof(Flow)), STORAGE_FLOW); + StorageFreeAll(f->storage, STORAGE_FLOW); } FlowStorageId FlowStorageRegister(const char *name, const unsigned int size, diff --git a/src/flow.h b/src/flow.h index 0a730e0ea3..c7b5867ea8 100644 --- a/src/flow.h +++ b/src/flow.h @@ -325,6 +325,8 @@ typedef unsigned short FlowStateType; /** Local Thread ID */ typedef uint16_t FlowThreadId; +#include "util-storage.h" + /** * \brief Flow data structure. * @@ -489,6 +491,8 @@ typedef struct Flow_ uint32_t tosrcpktcnt; uint64_t todstbytecnt; uint64_t tosrcbytecnt; + + Storage storage[]; } Flow; enum FlowState {