diff --git a/src/device-storage.c b/src/device-storage.c index f424888ecf..d4314c021e 100644 --- a/src/device-storage.c +++ b/src/device-storage.c @@ -75,7 +75,7 @@ LiveDevStorageId LiveDevStorageRegister(const char *name, const unsigned int siz int LiveDevSetStorageById(LiveDevice *d, LiveDevStorageId id, void *ptr) { - return StorageSetById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id.id, ptr); + return StorageSetById(d->storage, STORAGE_DEVICE, id.id, ptr); } /** @@ -88,7 +88,7 @@ int LiveDevSetStorageById(LiveDevice *d, LiveDevStorageId id, void *ptr) void *LiveDevGetStorageById(LiveDevice *d, LiveDevStorageId id) { - return StorageGetById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id.id); + return StorageGetById(d->storage, STORAGE_DEVICE, id.id); } /** @@ -99,19 +99,18 @@ void *LiveDevGetStorageById(LiveDevice *d, LiveDevStorageId id) void *LiveDevAllocStorageById(LiveDevice *d, LiveDevStorageId id) { - return StorageAllocByIdPrealloc( - (Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id.id); + return StorageAllocByIdPrealloc(d->storage, STORAGE_DEVICE, id.id); } void LiveDevFreeStorageById(LiveDevice *d, LiveDevStorageId id) { - StorageFreeById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id.id); + StorageFreeById(d->storage, STORAGE_DEVICE, id.id); } void LiveDevFreeStorage(LiveDevice *d) { if (LiveDevStorageSize() > 0) - StorageFreeAll((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE); + StorageFreeAll(d->storage, STORAGE_DEVICE); } diff --git a/src/util-device.h b/src/util-device.h index 0f756b78ca..d5a2d46caf 100644 --- a/src/util-device.h +++ b/src/util-device.h @@ -23,6 +23,7 @@ #endif /* HAVE_DPDK */ #include "queue.h" +#include "util-storage.h" #define OFFLOAD_FLAG_SG (1<<0) #define OFFLOAD_FLAG_TSO (1<<1) @@ -66,6 +67,8 @@ typedef struct LiveDevice_ { // DPDK resources that needs to be cleaned after workers are stopped and devices closed DPDKDeviceResources dpdk_vars; #endif + /** storage handle as a flex array member */ + Storage storage[]; } LiveDevice; typedef struct LiveDeviceName_ {