mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:35:23 +00:00
Driver: Revert tommyds' foreach_node() using.
This commit is contained in:
parent
6cb4f7f5d3
commit
3ff9ad0481
34
src/3rdparty/tommyds/tommyhashdyn.c
vendored
34
src/3rdparty/tommyds/tommyhashdyn.c
vendored
@ -216,6 +216,40 @@ TOMMY_API void tommy_hashdyn_foreach_arg(tommy_hashdyn* hashdyn, tommy_foreach_a
|
||||
}
|
||||
}
|
||||
|
||||
TOMMY_API void tommy_hashdyn_foreach_node(tommy_hashdyn* hashdyn, tommy_foreach_node_func* func)
|
||||
{
|
||||
tommy_size_t bucket_max = hashdyn->bucket_max;
|
||||
tommy_hashdyn_node** bucket = hashdyn->bucket;
|
||||
tommy_size_t pos;
|
||||
|
||||
for (pos = 0; pos < bucket_max; ++pos) {
|
||||
tommy_hashdyn_node* node = bucket[pos];
|
||||
|
||||
while (node) {
|
||||
tommy_hashdyn_node* next = node->next;
|
||||
func(node);
|
||||
node = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TOMMY_API void tommy_hashdyn_foreach_node_arg(tommy_hashdyn* hashdyn, tommy_foreach_node_arg_func* func, void* arg)
|
||||
{
|
||||
tommy_size_t bucket_max = hashdyn->bucket_max;
|
||||
tommy_hashdyn_node** bucket = hashdyn->bucket;
|
||||
tommy_size_t pos;
|
||||
|
||||
for (pos = 0; pos < bucket_max; ++pos) {
|
||||
tommy_hashdyn_node* node = bucket[pos];
|
||||
|
||||
while (node) {
|
||||
tommy_hashdyn_node* next = node->next;
|
||||
func(arg, node);
|
||||
node = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TOMMY_API tommy_size_t tommy_hashdyn_memory_usage(tommy_hashdyn* hashdyn)
|
||||
{
|
||||
return hashdyn->bucket_max * (tommy_size_t)sizeof(hashdyn->bucket[0])
|
||||
|
10
src/3rdparty/tommyds/tommyhashdyn.h
vendored
10
src/3rdparty/tommyds/tommyhashdyn.h
vendored
@ -278,6 +278,16 @@ TOMMY_API void tommy_hashdyn_foreach(tommy_hashdyn* hashdyn, tommy_foreach_func*
|
||||
*/
|
||||
TOMMY_API void tommy_hashdyn_foreach_arg(tommy_hashdyn* hashdyn, tommy_foreach_arg_func* func, void* arg);
|
||||
|
||||
/**
|
||||
* Calls the specified function for each node in the hashtable.
|
||||
*/
|
||||
TOMMY_API void tommy_hashdyn_foreach_node(tommy_hashdyn* hashdyn, tommy_foreach_node_func* func);
|
||||
|
||||
/**
|
||||
* Calls the specified function with an argument for each node in the hashtable.
|
||||
*/
|
||||
TOMMY_API void tommy_hashdyn_foreach_node_arg(tommy_hashdyn* hashdyn, tommy_foreach_node_arg_func* func, void* arg);
|
||||
|
||||
/**
|
||||
* Gets the number of elements.
|
||||
*/
|
||||
|
13
src/3rdparty/tommyds/tommytypes.h
vendored
13
src/3rdparty/tommyds/tommytypes.h
vendored
@ -316,6 +316,19 @@ typedef void tommy_foreach_func(void* obj);
|
||||
*/
|
||||
typedef void tommy_foreach_arg_func(void* arg, void* obj);
|
||||
|
||||
/**
|
||||
* Foreach node function.
|
||||
* \param node Pointer to the node to iterate.
|
||||
*/
|
||||
typedef void tommy_foreach_node_func(void* node);
|
||||
|
||||
/**
|
||||
* Foreach node function with an argument.
|
||||
* \param arg Pointer to a generic argument.
|
||||
* \param node Pointer to the node to iterate.
|
||||
*/
|
||||
typedef void tommy_foreach_node_arg_func(void* arg, void* node);
|
||||
|
||||
/******************************************************************************/
|
||||
/* bit hacks */
|
||||
|
||||
|
@ -188,13 +188,6 @@ fort_stat_proc_free (PFORT_STAT stat, PFORT_STAT_PROC proc)
|
||||
stat->proc_free = proc;
|
||||
}
|
||||
|
||||
static void
|
||||
fort_stat_proc_free_data (PFORT_STAT stat, void *data)
|
||||
{
|
||||
PFORT_STAT_PROC proc = (PFORT_STAT_PROC) fort_tommyhashdyn_node(data);
|
||||
fort_stat_proc_free(stat, proc);
|
||||
}
|
||||
|
||||
static PFORT_STAT_PROC
|
||||
fort_stat_proc_add (PFORT_STAT stat, UINT32 process_id)
|
||||
{
|
||||
@ -268,26 +261,12 @@ fort_flow_context_remove (PFORT_STAT stat, PFORT_FLOW flow)
|
||||
FwpsFlowRemoveContext0(flow_id, FWPS_LAYER_OUTBOUND_TRANSPORT_V4, stat->out_transport4_id);
|
||||
}
|
||||
|
||||
static void
|
||||
fort_flow_context_remove_data (PFORT_STAT stat, void *data)
|
||||
{
|
||||
PFORT_FLOW flow = (PFORT_FLOW) fort_tommyhashdyn_node(data);
|
||||
fort_flow_context_remove(stat, flow);
|
||||
}
|
||||
|
||||
static void
|
||||
fort_flow_close (PFORT_FLOW flow)
|
||||
{
|
||||
flow->opt.proc_index = FORT_PROC_BAD_INDEX;
|
||||
}
|
||||
|
||||
static void
|
||||
fort_flow_close_data (void *data)
|
||||
{
|
||||
PFORT_FLOW flow = (PFORT_FLOW) fort_tommyhashdyn_node(data);
|
||||
fort_flow_close(flow);
|
||||
}
|
||||
|
||||
static PFORT_FLOW
|
||||
fort_flow_get (PFORT_STAT stat, UINT64 flow_id, tommy_key_t flow_hash)
|
||||
{
|
||||
@ -391,8 +370,8 @@ fort_stat_close (PFORT_STAT stat)
|
||||
|
||||
stat->closed = TRUE;
|
||||
|
||||
tommy_hashdyn_foreach_arg(&stat->flows_map,
|
||||
fort_flow_context_remove_data, stat);
|
||||
tommy_hashdyn_foreach_node_arg(&stat->flows_map,
|
||||
fort_flow_context_remove, stat);
|
||||
|
||||
tommy_arrayof_done(&stat->procs);
|
||||
tommy_hashdyn_done(&stat->procs_map);
|
||||
@ -408,8 +387,8 @@ fort_stat_clear (PFORT_STAT stat)
|
||||
{
|
||||
fort_stat_proc_active_clear(stat);
|
||||
|
||||
tommy_hashdyn_foreach_arg(&stat->procs_map, fort_stat_proc_free_data, stat);
|
||||
tommy_hashdyn_foreach(&stat->flows_map, fort_flow_close_data);
|
||||
tommy_hashdyn_foreach_node_arg(&stat->procs_map, fort_stat_proc_free, stat);
|
||||
tommy_hashdyn_foreach_node(&stat->flows_map, fort_flow_close);
|
||||
|
||||
RtlZeroMemory(stat->groups, sizeof(stat->groups));
|
||||
}
|
||||
|
@ -53,6 +53,3 @@ fort_tommy_realloc (PVOID p, SIZE_T new_size)
|
||||
#include "..\3rdparty\tommyds\tommylist.c"
|
||||
#include "..\3rdparty\tommyds\tommyhash.c"
|
||||
#include "..\3rdparty\tommyds\tommyhashdyn.c"
|
||||
|
||||
#define fort_tommyhashdyn_node(datap) \
|
||||
((tommy_hashdyn_node *) ((char *) (datap) - offsetof(tommy_hashdyn_node, data)))
|
||||
|
Loading…
Reference in New Issue
Block a user