flow/storage: use flex array instead of calculated ptr

pull/9939/head
Victor Julien 1 year ago committed by Victor Julien
parent c1b920d056
commit d405efd3f6

@ -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,

@ -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 {

Loading…
Cancel
Save