diff --git a/plugins/ndpi/ndpi.c b/plugins/ndpi/ndpi.c index ac8005c3f2..e5983e40fe 100644 --- a/plugins/ndpi/ndpi.c +++ b/plugins/ndpi/ndpi.c @@ -573,13 +573,13 @@ static void NdpiInit(void) SCLogDebug("Initializing nDPI plugin"); /* Register thread storage. */ - thread_storage_id = ThreadStorageRegister("ndpi", sizeof(void *), ThreadStorageFree); + thread_storage_id = ThreadStorageRegister("ndpi", ThreadStorageFree); if (thread_storage_id.id < 0) { FatalError("Failed to register nDPI thread storage"); } /* Register flow storage. */ - flow_storage_id = FlowStorageRegister("ndpi", sizeof(void *), FlowStorageFree); + flow_storage_id = FlowStorageRegister("ndpi", FlowStorageFree); if (flow_storage_id.id < 0) { FatalError("Failed to register nDPI flow storage"); } diff --git a/src/app-layer-expectation.c b/src/app-layer-expectation.c index b24edf474c..ced18d05f2 100644 --- a/src/app-layer-expectation.c +++ b/src/app-layer-expectation.c @@ -145,9 +145,8 @@ uint64_t ExpectationGetCounter(void) void AppLayerExpectationSetup(void) { - g_ippair_expectation_id = - IPPairStorageRegister("expectation", sizeof(void *), ExpectationListFree); - g_flow_expectation_id = FlowStorageRegister("expectation", sizeof(void *), ExpectationDataFree); + g_ippair_expectation_id = IPPairStorageRegister("expectation", ExpectationListFree); + g_flow_expectation_id = FlowStorageRegister("expectation", ExpectationDataFree); SC_ATOMIC_INIT(expectation_count); } diff --git a/src/detect-engine-tag.c b/src/detect-engine-tag.c index 51e1b6e5b5..373f04b12f 100644 --- a/src/detect-engine-tag.c +++ b/src/detect-engine-tag.c @@ -53,11 +53,11 @@ void TagInitCtx(void) { SC_ATOMIC_INIT(num_tags); - host_tag_id = HostStorageRegister("tag", sizeof(void *), DetectTagDataListFree); + host_tag_id = HostStorageRegister("tag", DetectTagDataListFree); if (host_tag_id.id == -1) { FatalError("Can't initiate host storage for tag"); } - flow_tag_id = FlowStorageRegister("tag", sizeof(void *), DetectTagDataListFree); + flow_tag_id = FlowStorageRegister("tag", DetectTagDataListFree); if (flow_tag_id.id == -1) { FatalError("Can't initiate flow storage for tag"); } diff --git a/src/device-storage.c b/src/device-storage.c index 3b2935d2bb..2802be3d82 100644 --- a/src/device-storage.c +++ b/src/device-storage.c @@ -49,7 +49,6 @@ unsigned int LiveDevStorageSize(void) * \brief Register a LiveDevice storage * * \param name the name of the storage - * \param size integer coding the size of the stored value (sizeof(void *) is expected here) * \param Free free function for the new storage * * \retval The ID of the newly register storage that will be used to access data @@ -57,10 +56,9 @@ unsigned int LiveDevStorageSize(void) * It has to be called once during the init of the sub system */ -LiveDevStorageId LiveDevStorageRegister( - const char *name, const unsigned int size, void (*Free)(void *)) +LiveDevStorageId LiveDevStorageRegister(const char *name, void (*Free)(void *)) { - int id = StorageRegister(STORAGE_DEVICE, name, size, Free); + int id = StorageRegister(STORAGE_DEVICE, name, Free); LiveDevStorageId ldsi = { .id = id }; return ldsi; } diff --git a/src/device-storage.h b/src/device-storage.h index 9c84135f73..e59bc1aa6a 100644 --- a/src/device-storage.h +++ b/src/device-storage.h @@ -39,7 +39,6 @@ int LiveDevSetStorageById(LiveDevice *d, LiveDevStorageId id, void *ptr); void LiveDevFreeStorage(LiveDevice *d); -LiveDevStorageId LiveDevStorageRegister( - const char *name, const unsigned int size, void (*Free)(void *)); +LiveDevStorageId LiveDevStorageRegister(const char *name, void (*Free)(void *)); #endif /* SURICATA_DEVICE_STORAGE_H */ diff --git a/src/flow-storage.c b/src/flow-storage.c index cdb77db0d3..0038e53709 100644 --- a/src/flow-storage.c +++ b/src/flow-storage.c @@ -58,9 +58,9 @@ void FlowFreeStorage(Flow *f) StorageFreeAll(f->storage, STORAGE_FLOW); } -FlowStorageId FlowStorageRegister(const char *name, const unsigned int size, void (*Free)(void *)) +FlowStorageId FlowStorageRegister(const char *name, void (*Free)(void *)) { - int id = StorageRegister(STORAGE_FLOW, name, size, Free); + int id = StorageRegister(STORAGE_FLOW, name, Free); FlowStorageId fsi = { .id = id }; return fsi; } @@ -78,11 +78,11 @@ static int FlowStorageTest01(void) StorageCleanup(); StorageInit(); - FlowStorageId id1 = FlowStorageRegister("test", sizeof(void *), StorageTestFree); + FlowStorageId id1 = FlowStorageRegister("test", StorageTestFree); FAIL_IF(id1.id < 0); - FlowStorageId id2 = FlowStorageRegister("variable", sizeof(void *), StorageTestFree); + FlowStorageId id2 = FlowStorageRegister("variable", StorageTestFree); FAIL_IF(id2.id < 0); - FlowStorageId id3 = FlowStorageRegister("store", sizeof(void *), StorageTestFree); + FlowStorageId id3 = FlowStorageRegister("store", StorageTestFree); FAIL_IF(id3.id < 0); FAIL_IF(StorageFinalize() < 0); @@ -128,7 +128,7 @@ static int FlowStorageTest02(void) StorageCleanup(); StorageInit(); - FlowStorageId id1 = FlowStorageRegister("test", sizeof(void *), StorageTestFree); + FlowStorageId id1 = FlowStorageRegister("test", StorageTestFree); FAIL_IF(id1.id < 0); FAIL_IF(StorageFinalize() < 0); @@ -159,11 +159,11 @@ static int FlowStorageTest03(void) StorageCleanup(); StorageInit(); - FlowStorageId id1 = FlowStorageRegister("test1", sizeof(void *), StorageTestFree); + FlowStorageId id1 = FlowStorageRegister("test1", StorageTestFree); FAIL_IF(id1.id < 0); - FlowStorageId id2 = FlowStorageRegister("test2", sizeof(void *), StorageTestFree); + FlowStorageId id2 = FlowStorageRegister("test2", StorageTestFree); FAIL_IF(id2.id < 0); - FlowStorageId id3 = FlowStorageRegister("test3", sizeof(void *), StorageTestFree); + FlowStorageId id3 = FlowStorageRegister("test3", StorageTestFree); FAIL_IF(id3.id < 0); FAIL_IF(StorageFinalize() < 0); diff --git a/src/flow-storage.h b/src/flow-storage.h index e193053013..54c2a5c5da 100644 --- a/src/flow-storage.h +++ b/src/flow-storage.h @@ -42,6 +42,6 @@ void FlowFreeStorage(Flow *h); void RegisterFlowStorageTests(void); -FlowStorageId FlowStorageRegister(const char *name, const unsigned int size, void (*Free)(void *)); +FlowStorageId FlowStorageRegister(const char *name, void (*Free)(void *)); #endif /* SURICATA_FLOW_STORAGE_H */ diff --git a/src/flow-util.c b/src/flow-util.c index 199997ff54..1c4dca9c13 100644 --- a/src/flow-util.c +++ b/src/flow-util.c @@ -239,7 +239,7 @@ static void FlowBypassFree(void *x) void RegisterFlowBypassInfo(void) { - g_bypass_info_id = FlowStorageRegister("bypass_counters", sizeof(void *), FlowBypassFree); + g_bypass_info_id = FlowStorageRegister("bypass_counters", FlowBypassFree); } void FlowEndCountersRegister(ThreadVars *t, FlowEndCounters *fec) diff --git a/src/host-bit.c b/src/host-bit.c index 613a616914..006ec28977 100644 --- a/src/host-bit.c +++ b/src/host-bit.c @@ -48,7 +48,7 @@ static void HostBitFreeAll(void *store) void HostBitInitCtx(void) { - host_bit_id = HostStorageRegister("bit", sizeof(void *), HostBitFreeAll); + host_bit_id = HostStorageRegister("bit", HostBitFreeAll); if (host_bit_id.id == -1) { FatalError("Can't initiate host storage for bits"); } diff --git a/src/host-storage.c b/src/host-storage.c index e9afde83b7..211d45f5c7 100644 --- a/src/host-storage.c +++ b/src/host-storage.c @@ -47,7 +47,6 @@ unsigned int HostStorageSize(void) * \brief Register a Host storage * * \param name the name of the storage - * \param size integer coding the size of the stored value (sizeof(void *) is expected here) * \param Free free function for the new storage * * \retval The ID of the newly register storage that will be used to access data @@ -55,9 +54,9 @@ unsigned int HostStorageSize(void) * It has to be called once during the init of the sub system */ -HostStorageId HostStorageRegister(const char *name, const unsigned int size, void (*Free)(void *)) +HostStorageId HostStorageRegister(const char *name, void (*Free)(void *)) { - int id = StorageRegister(STORAGE_HOST, name, size, Free); + int id = StorageRegister(STORAGE_HOST, name, Free); HostStorageId hsi = { .id = id }; return hsi; } @@ -114,11 +113,11 @@ static int HostStorageTest01(void) StorageCleanup(); StorageInit(); - HostStorageId id1 = HostStorageRegister("test", sizeof(void *), StorageTestFree); + HostStorageId id1 = HostStorageRegister("test", StorageTestFree); FAIL_IF(id1.id < 0); - HostStorageId id2 = HostStorageRegister("variable", sizeof(void *), StorageTestFree); + HostStorageId id2 = HostStorageRegister("variable", StorageTestFree); FAIL_IF(id2.id < 0); - HostStorageId id3 = HostStorageRegister("store", sizeof(void *), StorageTestFree); + HostStorageId id3 = HostStorageRegister("store", StorageTestFree); FAIL_IF(id3.id < 0); FAIL_IF(StorageFinalize() < 0); @@ -168,7 +167,7 @@ static int HostStorageTest02(void) StorageCleanup(); StorageInit(); - HostStorageId id1 = HostStorageRegister("test", sizeof(void *), StorageTestFree); + HostStorageId id1 = HostStorageRegister("test", StorageTestFree); FAIL_IF(id1.id < 0); FAIL_IF(StorageFinalize() < 0); @@ -204,11 +203,11 @@ static int HostStorageTest03(void) StorageCleanup(); StorageInit(); - HostStorageId id1 = HostStorageRegister("test1", sizeof(void *), StorageTestFree); + HostStorageId id1 = HostStorageRegister("test1", StorageTestFree); FAIL_IF(id1.id < 0); - HostStorageId id2 = HostStorageRegister("test2", sizeof(void *), StorageTestFree); + HostStorageId id2 = HostStorageRegister("test2", StorageTestFree); FAIL_IF(id2.id < 0); - HostStorageId id3 = HostStorageRegister("test3", sizeof(void *), StorageTestFree); + HostStorageId id3 = HostStorageRegister("test3", StorageTestFree); FAIL_IF(id3.id < 0); FAIL_IF(StorageFinalize() < 0); diff --git a/src/host-storage.h b/src/host-storage.h index 9d6bcbcdaa..695768bab2 100644 --- a/src/host-storage.h +++ b/src/host-storage.h @@ -41,6 +41,6 @@ void HostFreeStorage(Host *h); void RegisterHostStorageTests(void); -HostStorageId HostStorageRegister(const char *name, const unsigned int size, void (*Free)(void *)); +HostStorageId HostStorageRegister(const char *name, void (*Free)(void *)); #endif /* SURICATA_HOST_STORAGE_H */ diff --git a/src/ippair-bit.c b/src/ippair-bit.c index b1d009ea57..cb3237bd43 100644 --- a/src/ippair-bit.c +++ b/src/ippair-bit.c @@ -48,7 +48,7 @@ static void XBitFreeAll(void *store) void IPPairBitInitCtx(void) { - g_ippair_bit_storage_id = IPPairStorageRegister("bit", sizeof(void *), XBitFreeAll); + g_ippair_bit_storage_id = IPPairStorageRegister("bit", XBitFreeAll); if (g_ippair_bit_storage_id.id == -1) { FatalError("Can't initiate ippair storage for bits"); } diff --git a/src/ippair-storage.c b/src/ippair-storage.c index 02285c84d4..f57717805d 100644 --- a/src/ippair-storage.c +++ b/src/ippair-storage.c @@ -48,10 +48,9 @@ void IPPairFreeStorage(IPPair *h) StorageFreeAll(h->storage, STORAGE_IPPAIR); } -IPPairStorageId IPPairStorageRegister( - const char *name, const unsigned int size, void (*Free)(void *)) +IPPairStorageId IPPairStorageRegister(const char *name, void (*Free)(void *)) { - int id = StorageRegister(STORAGE_IPPAIR, name, size, Free); + int id = StorageRegister(STORAGE_IPPAIR, name, Free); IPPairStorageId ippsi = { .id = id }; return ippsi; } @@ -69,11 +68,11 @@ static int IPPairStorageTest01(void) StorageCleanup(); StorageInit(); - IPPairStorageId id1 = IPPairStorageRegister("test", sizeof(void *), StorageTestFree); + IPPairStorageId id1 = IPPairStorageRegister("test", StorageTestFree); FAIL_IF(id1.id < 0); - IPPairStorageId id2 = IPPairStorageRegister("variable", sizeof(void *), StorageTestFree); + IPPairStorageId id2 = IPPairStorageRegister("variable", StorageTestFree); FAIL_IF(id2.id < 0); - IPPairStorageId id3 = IPPairStorageRegister("store", sizeof(void *), StorageTestFree); + IPPairStorageId id3 = IPPairStorageRegister("store", StorageTestFree); FAIL_IF(id3.id < 0); FAIL_IF(StorageFinalize() < 0); @@ -125,7 +124,7 @@ static int IPPairStorageTest02(void) StorageCleanup(); StorageInit(); - IPPairStorageId id1 = IPPairStorageRegister("test", sizeof(void *), StorageTestFree); + IPPairStorageId id1 = IPPairStorageRegister("test", StorageTestFree); FAIL_IF(id1.id < 0); FAIL_IF(StorageFinalize() < 0); @@ -164,11 +163,11 @@ static int IPPairStorageTest03(void) StorageCleanup(); StorageInit(); - IPPairStorageId id1 = IPPairStorageRegister("test1", sizeof(void *), StorageTestFree); + IPPairStorageId id1 = IPPairStorageRegister("test1", StorageTestFree); FAIL_IF(id1.id < 0); - IPPairStorageId id2 = IPPairStorageRegister("test2", sizeof(void *), StorageTestFree); + IPPairStorageId id2 = IPPairStorageRegister("test2", StorageTestFree); FAIL_IF(id2.id < 0); - IPPairStorageId id3 = IPPairStorageRegister("test3", sizeof(void *), StorageTestFree); + IPPairStorageId id3 = IPPairStorageRegister("test3", StorageTestFree); FAIL_IF(id3.id < 0); FAIL_IF(StorageFinalize() < 0); diff --git a/src/ippair-storage.h b/src/ippair-storage.h index 26136cb150..3c853f33a5 100644 --- a/src/ippair-storage.h +++ b/src/ippair-storage.h @@ -41,7 +41,6 @@ void IPPairFreeStorage(IPPair *h); void RegisterIPPairStorageTests(void); -IPPairStorageId IPPairStorageRegister( - const char *name, const unsigned int size, void (*Free)(void *)); +IPPairStorageId IPPairStorageRegister(const char *name, void (*Free)(void *)); #endif /* SURICATA_IPPAIR_STORAGE_H */ diff --git a/src/thread-storage.c b/src/thread-storage.c index d3e3d7509e..ab8e6606a7 100644 --- a/src/thread-storage.c +++ b/src/thread-storage.c @@ -48,10 +48,9 @@ void ThreadFreeStorage(ThreadVars *tv) StorageFreeAll(tv->storage, storage_type); } -ThreadStorageId ThreadStorageRegister( - const char *name, const unsigned int size, void (*Free)(void *)) +ThreadStorageId ThreadStorageRegister(const char *name, void (*Free)(void *)) { - int id = StorageRegister(storage_type, name, size, Free); + int id = StorageRegister(storage_type, name, Free); ThreadStorageId tsi = { .id = id }; return tsi; } @@ -68,13 +67,13 @@ static int ThreadStorageTest01(void) StorageCleanup(); StorageInit(); - ThreadStorageId id1 = ThreadStorageRegister("test", sizeof(void *), StorageTestFree); + ThreadStorageId id1 = ThreadStorageRegister("test", StorageTestFree); FAIL_IF(id1.id < 0); - ThreadStorageId id2 = ThreadStorageRegister("variable", sizeof(void *), StorageTestFree); + ThreadStorageId id2 = ThreadStorageRegister("variable", StorageTestFree); FAIL_IF(id2.id < 0); - ThreadStorageId id3 = ThreadStorageRegister("store", sizeof(void *), StorageTestFree); + ThreadStorageId id3 = ThreadStorageRegister("store", StorageTestFree); FAIL_IF(id3.id < 0); FAIL_IF(StorageFinalize() < 0); @@ -123,7 +122,7 @@ static int ThreadStorageTest02(void) StorageCleanup(); StorageInit(); - ThreadStorageId id1 = ThreadStorageRegister("test", sizeof(void *), StorageTestFree); + ThreadStorageId id1 = ThreadStorageRegister("test", StorageTestFree); FAIL_IF(id1.id < 0); FAIL_IF(StorageFinalize() < 0); @@ -153,13 +152,13 @@ static int ThreadStorageTest03(void) StorageCleanup(); StorageInit(); - ThreadStorageId id1 = ThreadStorageRegister("test1", sizeof(void *), StorageTestFree); + ThreadStorageId id1 = ThreadStorageRegister("test1", StorageTestFree); FAIL_IF(id1.id < 0); - ThreadStorageId id2 = ThreadStorageRegister("test2", sizeof(void *), StorageTestFree); + ThreadStorageId id2 = ThreadStorageRegister("test2", StorageTestFree); FAIL_IF(id2.id < 0); - ThreadStorageId id3 = ThreadStorageRegister("test3", sizeof(void *), StorageTestFree); + ThreadStorageId id3 = ThreadStorageRegister("test3", StorageTestFree); FAIL_IF(id3.id < 0); FAIL_IF(StorageFinalize() < 0); diff --git a/src/thread-storage.h b/src/thread-storage.h index 698cbe8ce4..5c54e4dd35 100644 --- a/src/thread-storage.h +++ b/src/thread-storage.h @@ -38,7 +38,6 @@ void ThreadFreeStorage(ThreadVars *tv); void RegisterThreadStorageTests(void); -ThreadStorageId ThreadStorageRegister( - const char *name, const unsigned int size, void (*Free)(void *)); +ThreadStorageId ThreadStorageRegister(const char *name, void (*Free)(void *)); #endif /* SURICATA_THREAD_STORAGE_H */ diff --git a/src/util-device.c b/src/util-device.c index 92fc6968e4..39976ee148 100644 --- a/src/util-device.c +++ b/src/util-device.c @@ -484,8 +484,7 @@ static void LiveDevExtensionFree(void *x) */ void LiveDevRegisterExtension(void) { - g_bypass_storage_id = - LiveDevStorageRegister("bypass_stats", sizeof(void *), LiveDevExtensionFree); + g_bypass_storage_id = LiveDevStorageRegister("bypass_stats", LiveDevExtensionFree); } /** diff --git a/src/util-ebpf.c b/src/util-ebpf.c index 56248c8fc9..48c9259e5e 100644 --- a/src/util-ebpf.c +++ b/src/util-ebpf.c @@ -929,8 +929,8 @@ int EBPFCheckBypassedFlowCreate(ThreadVars *th_v, struct timespec *curtime, void void EBPFRegisterExtension(void) { - g_livedev_storage_id = LiveDevStorageRegister("bpfmap", sizeof(void *), BpfMapsInfoFree); - g_flow_storage_id = FlowStorageRegister("bypassedlist", sizeof(void *), BypassedListFree); + g_livedev_storage_id = LiveDevStorageRegister("bpfmap", BpfMapsInfoFree); + g_flow_storage_id = FlowStorageRegister("bypassedlist", BypassedListFree); } diff --git a/src/util-flow-rate.c b/src/util-flow-rate.c index f1ec8c5e1d..c9637e5189 100644 --- a/src/util-flow-rate.c +++ b/src/util-flow-rate.c @@ -90,7 +90,7 @@ void FlowRateRegisterFlowStorage(void) } flow_rate_config.interval = SCTIME_ADD_SECS(interval, secs); - g_flowrate_storage_id = FlowStorageRegister("flowrate", sizeof(void *), FlowRateStoreFree); + g_flowrate_storage_id = FlowStorageRegister("flowrate", FlowRateStoreFree); } bool FlowRateStorageEnabled(void) diff --git a/src/util-macset.c b/src/util-macset.c index 72e4b9ef5b..5186222182 100644 --- a/src/util-macset.c +++ b/src/util-macset.c @@ -72,8 +72,8 @@ void MacSetRegisterFlowStorage(void) const char *ethernet = SCConfNodeLookupChildValue(node->head.tqh_first, "ethernet"); if (ethernet != NULL && SCConfValIsTrue(ethernet)) { - g_macset_storage_id = FlowStorageRegister( - "macset", sizeof(void *), (void (*)(void *))MacSetFree); + g_macset_storage_id = + FlowStorageRegister("macset", (void (*)(void *))MacSetFree); return; } } diff --git a/src/util-storage.c b/src/util-storage.c index 94910d9eda..9ab537bf03 100644 --- a/src/util-storage.c +++ b/src/util-storage.c @@ -31,7 +31,6 @@ typedef struct StorageMapping_ { const char *name; StorageEnum type; // host, flow, tx, stream, ssn, etc - unsigned int size; void (*Free)(void *); } StorageMapping; @@ -98,14 +97,12 @@ void StorageCleanup(void) storage_list = NULL; } -int StorageRegister( - const StorageEnum type, const char *name, const unsigned int size, void (*Free)(void *)) +int StorageRegister(const StorageEnum type, const char *name, void (*Free)(void *)) { if (storage_registration_closed) return -1; - if (type >= STORAGE_MAX || name == NULL || strlen(name) == 0 || size == 0 || - size != sizeof(void *) || Free == NULL) + if (type >= STORAGE_MAX || name == NULL || strlen(name) == 0 || Free == NULL) return -1; StorageList *list = storage_list; @@ -126,7 +123,6 @@ int StorageRegister( entry->map.type = type; entry->map.name = name; - entry->map.size = size; entry->map.Free = Free; entry->id = storage_max_id[type]++; @@ -168,7 +164,6 @@ int StorageFinalize(void) if (storage_map[entry->map.type] != NULL) { storage_map[entry->map.type][entry->id].name = entry->map.name; storage_map[entry->map.type][entry->id].type = entry->map.type; - storage_map[entry->map.type][entry->id].size = entry->map.size; storage_map[entry->map.type][entry->id].Free = entry->map.Free; } @@ -186,8 +181,7 @@ int StorageFinalize(void) int j; for (j = 0; j < storage_max_id[i]; j++) { StorageMapping *m = &storage_map[i][j]; - SCLogDebug("type \"%s\" name \"%s\" size \"%"PRIuMAX"\"", - StoragePrintType(m->type), m->name, (uintmax_t)m->size); + SCLogDebug("type \"%s\" name \"%s\"", StoragePrintType(m->type), m->name); } } #endif diff --git a/src/util-storage.h b/src/util-storage.h index 25773eed53..d92880b526 100644 --- a/src/util-storage.h +++ b/src/util-storage.h @@ -48,14 +48,9 @@ void StorageCleanup(void); * * \param type type from StorageEnum * \param name name - * \param size size of the per instance storage * \param Free free function for per instance storage - * - * \note if size == ptr size (so sizeof(void *)) and Alloc == NULL the API just - * gives the caller a ptr to store something it alloc'ed itself. */ -int StorageRegister( - const StorageEnum type, const char *name, const unsigned int size, void (*Free)(void *)); +int StorageRegister(const StorageEnum type, const char *name, void (*Free)(void *)); int StorageFinalize(void); unsigned int StorageGetCnt(const StorageEnum type);