[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: simplify GNUNET_CONTAINER_h
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: simplify GNUNET_CONTAINER_heap_update_cost API |
Date: |
Mon, 16 Jan 2017 11:24:33 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new d47358263 simplify GNUNET_CONTAINER_heap_update_cost API
d47358263 is described below
commit d473582634ea55c2a412da1360b05a2898ed568d
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Jan 16 11:24:30 2017 +0100
simplify GNUNET_CONTAINER_heap_update_cost API
---
src/datacache/plugin_datacache_heap.c | 3 +--
src/datastore/plugin_datastore_heap.c | 8 +++-----
src/exit/gnunet-daemon-exit.c | 5 ++---
src/include/gnunet_container_lib.h | 8 +++-----
src/transport/plugin_transport_udp.c | 9 ++++-----
src/util/container_heap.c | 27 +++++++--------------------
src/util/test_container_heap.c | 13 +++++++------
src/vpn/gnunet-service-vpn.c | 12 ++++--------
8 files changed, 31 insertions(+), 54 deletions(-)
diff --git a/src/datacache/plugin_datacache_heap.c
b/src/datacache/plugin_datacache_heap.c
index 185d54f2f..49e60bca1 100644
--- a/src/datacache/plugin_datacache_heap.c
+++ b/src/datacache/plugin_datacache_heap.c
@@ -180,8 +180,7 @@ put_cb (void *cls,
GNUNET_memcpy (val->path_info,
put_ctx->path_info,
put_ctx->path_info_len * sizeof (struct GNUNET_PeerIdentity));
- GNUNET_CONTAINER_heap_update_cost (put_ctx->heap,
- val->hn,
+ GNUNET_CONTAINER_heap_update_cost (val->hn,
val->discard_time.abs_value_us);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Got same value for key %s and type %d (size %u vs %u)\n",
diff --git a/src/datastore/plugin_datastore_heap.c
b/src/datastore/plugin_datastore_heap.c
index 51f61764c..977d599d2 100644
--- a/src/datastore/plugin_datastore_heap.c
+++ b/src/datastore/plugin_datastore_heap.c
@@ -331,7 +331,7 @@ struct GetContext
* The plugin.
*/
struct Plugin *plugin;
-
+
/**
* Requested value hash.
*/
@@ -608,7 +608,7 @@ heap_plugin_get_expiration (void *cls, PluginDatumProcessor
proc,
* priority should be added to the existing priority, ignoring the
* priority in value.
*
- * @param cls our "struct Plugin*"
+ * @param cls our `struct Plugin *`
* @param uid unique identifier of the datum
* @param delta by how much should the priority
* change? If priority + delta < 0 the
@@ -628,7 +628,6 @@ heap_plugin_update (void *cls,
PluginUpdateCont cont,
void *cont_cls)
{
- struct Plugin *plugin = cls;
struct Value *value;
value = (struct Value*) (long) uid;
@@ -636,8 +635,7 @@ heap_plugin_update (void *cls,
if (value->expiration.abs_value_us != expire.abs_value_us)
{
value->expiration = expire;
- GNUNET_CONTAINER_heap_update_cost (plugin->by_expiration,
- value->expire_heap,
+ GNUNET_CONTAINER_heap_update_cost (value->expire_heap,
expire.abs_value_us);
}
if ( (delta < 0) && (value->priority < - delta) )
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 790780aa6..92acc61cd 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -747,9 +747,8 @@ get_redirect_state (int af,
return NULL;
/* Mark this connection as freshly used */
if (NULL == state_key)
- GNUNET_CONTAINER_heap_update_cost (connections_heap,
- state->specifics.tcp_udp.heap_node,
- GNUNET_TIME_absolute_get
().abs_value_us);
+ GNUNET_CONTAINER_heap_update_cost (state->specifics.tcp_udp.heap_node,
+ GNUNET_TIME_absolute_get
().abs_value_us);
return state;
}
diff --git a/src/include/gnunet_container_lib.h
b/src/include/gnunet_container_lib.h
index 03c47c201..075c0822a 100644
--- a/src/include/gnunet_container_lib.h
+++ b/src/include/gnunet_container_lib.h
@@ -1915,8 +1915,8 @@ GNUNET_CONTAINER_heap_get_size (const struct
GNUNET_CONTAINER_Heap *heap);
* @return cost of the node
*/
GNUNET_CONTAINER_HeapCostType
-GNUNET_CONTAINER_heap_node_get_cost (const struct GNUNET_CONTAINER_HeapNode
- *node);
+GNUNET_CONTAINER_heap_node_get_cost (const struct GNUNET_CONTAINER_HeapNode
*node);
+
/**
* @ingroup heap
@@ -2006,13 +2006,11 @@ GNUNET_CONTAINER_heap_remove_node (struct
GNUNET_CONTAINER_HeapNode *node);
* @ingroup heap
* Updates the cost of any node in the tree
*
- * @param heap heap to modify
* @param node node for which the cost is to be changed
* @param new_cost new cost for the node
*/
void
-GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap,
- struct GNUNET_CONTAINER_HeapNode *node,
+GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_HeapNode *node,
GNUNET_CONTAINER_HeapCostType new_cost);
diff --git a/src/transport/plugin_transport_udp.c
b/src/transport/plugin_transport_udp.c
index 8281e48c5..fd8493e5f 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -1246,7 +1246,7 @@ udp_plugin_check_address (void *cls,
if (sizeof(struct IPv4UdpAddress) == addrlen)
{
struct sockaddr_in s4;
-
+
v4 = (const struct IPv4UdpAddress *) addr;
if (GNUNET_OK != check_port (plugin,
ntohs (v4->u4_port)))
@@ -1258,7 +1258,7 @@ udp_plugin_check_address (void *cls,
#endif
s4.sin_port = v4->u4_port;
s4.sin_addr.s_addr = v4->ipv4_addr;
-
+
if (GNUNET_OK !=
GNUNET_NAT_test_address (plugin->nat,
&s4,
@@ -3052,8 +3052,7 @@ read_process_fragment (struct Plugin *plugin,
msg))
{
/* keep this 'rc' from expiring */
- GNUNET_CONTAINER_heap_update_cost (plugin->defrag_ctxs,
- d_ctx->hnode,
+ GNUNET_CONTAINER_heap_update_cost (d_ctx->hnode,
(GNUNET_CONTAINER_HeapCostType)
now.abs_value_us);
}
if (GNUNET_CONTAINER_heap_get_size (plugin->defrag_ctxs) >
@@ -3539,7 +3538,7 @@ udp_plugin_select_v4 (void *cls)
{
struct Plugin *plugin = cls;
const struct GNUNET_SCHEDULER_TaskContext *tc;
-
+
plugin->select_task_v4 = NULL;
if (NULL == plugin->sockv4)
return;
diff --git a/src/util/container_heap.c b/src/util/container_heap.c
index 4f82fb076..1ead5ec6d 100644
--- a/src/util/container_heap.c
+++ b/src/util/container_heap.c
@@ -541,36 +541,23 @@ GNUNET_CONTAINER_heap_remove_node (struct
GNUNET_CONTAINER_HeapNode *node)
/**
* Updates the cost of any node in the tree
*
- * @param heap heap to modify
* @param node node for which the cost is to be changed
* @param new_cost new cost for the node
*/
void
-GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap,
- struct GNUNET_CONTAINER_HeapNode *node,
+GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_HeapNode *node,
GNUNET_CONTAINER_HeapCostType new_cost)
{
-#if EXTRA_CHECKS
- GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
- (heap->size == heap->root->tree_size + 1));
- CHECK (heap->root);
-#endif
+ struct GNUNET_CONTAINER_Heap *heap = node->heap;
+
remove_node (node);
-#if EXTRA_CHECKS
- CHECK (heap->root);
- GNUNET_assert (((heap->size == 1) && (heap->root == NULL)) ||
- (heap->size == heap->root->tree_size + 2));
-#endif
node->cost = new_cost;
- if (heap->root == NULL)
+ if (NULL == heap->root)
heap->root = node;
else
- insert_node (heap, heap->root, node);
-#if EXTRA_CHECKS
- CHECK (heap->root);
- GNUNET_assert (((heap->size == 0) && (heap->root == NULL)) ||
- (heap->size == heap->root->tree_size + 1));
-#endif
+ insert_node (heap,
+ heap->root,
+ node);
}
diff --git a/src/util/test_container_heap.c b/src/util/test_container_heap.c
index f115159bf..82b0e9523 100644
--- a/src/util/test_container_heap.c
+++ b/src/util/test_container_heap.c
@@ -28,7 +28,8 @@
#include "gnunet_util_lib.h"
static int
-iterator_callback (void *cls, struct GNUNET_CONTAINER_HeapNode *node,
+iterator_callback (void *cls,
+ struct GNUNET_CONTAINER_HeapNode *node,
void *element, GNUNET_CONTAINER_HeapCostType cost)
{
return GNUNET_OK;
@@ -93,12 +94,12 @@ check ()
GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL);
n3 = GNUNET_CONTAINER_heap_insert (myHeap, "15", 5);
- GNUNET_CONTAINER_heap_update_cost (myHeap, n3, 15);
+ GNUNET_CONTAINER_heap_update_cost (n3, 15);
GNUNET_assert (2 == GNUNET_CONTAINER_heap_get_size (myHeap));
GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL);
n4 = GNUNET_CONTAINER_heap_insert (myHeap, "50", 50);
- GNUNET_CONTAINER_heap_update_cost (myHeap, n4, 50);
+ GNUNET_CONTAINER_heap_update_cost (n4, 50);
GNUNET_assert (3 == GNUNET_CONTAINER_heap_get_size (myHeap));
GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL);
@@ -109,7 +110,7 @@ check ()
r = GNUNET_CONTAINER_heap_remove_root (myHeap); /* n1 */
GNUNET_assert (NULL != r);
GNUNET_assert (0 == strcmp ("11", r));
- GNUNET_CONTAINER_heap_update_cost (myHeap, n6, 200);
+ GNUNET_CONTAINER_heap_update_cost (n6, 200);
GNUNET_CONTAINER_heap_remove_node (n3);
r = GNUNET_CONTAINER_heap_remove_root (myHeap); /* n4 */
GNUNET_assert (NULL != r);
@@ -128,7 +129,7 @@ check ()
myHeap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
- GNUNET_CONTAINER_heap_update_cost (myHeap, n1, 15);
+ GNUNET_CONTAINER_heap_update_cost (n1, 15);
r = GNUNET_CONTAINER_heap_remove_node (n1);
GNUNET_assert (NULL != r);
@@ -213,7 +214,7 @@ check ()
myHeap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MAX);
n1 = GNUNET_CONTAINER_heap_insert (myHeap, "10", 10);
- GNUNET_CONTAINER_heap_update_cost (myHeap, n1, 15);
+ GNUNET_CONTAINER_heap_update_cost (n1, 15);
GNUNET_assert (0 == nstrcmp ("10", GNUNET_CONTAINER_heap_remove_node (n1)));
diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c
index 4c0978d5c..c66023c85 100644
--- a/src/vpn/gnunet-service-vpn.c
+++ b/src/vpn/gnunet-service-vpn.c
@@ -1129,8 +1129,7 @@ route_packet (struct DestinationEntry *destination,
}
else
{
- GNUNET_CONTAINER_heap_update_cost (channel_heap,
- ts->heap_node,
+ GNUNET_CONTAINER_heap_update_cost (ts->heap_node,
GNUNET_TIME_absolute_get
().abs_value_us);
}
if (NULL == ts->channel)
@@ -2062,8 +2061,7 @@ receive_icmp_back (void *cls,
default:
GNUNET_assert (0);
}
- GNUNET_CONTAINER_heap_update_cost (channel_heap,
- ts->heap_node,
+ GNUNET_CONTAINER_heap_update_cost (ts->heap_node,
GNUNET_TIME_absolute_get ().abs_value_us);
GNUNET_CADET_receive_done (channel);
return GNUNET_OK;
@@ -2218,8 +2216,7 @@ receive_udp_back (void *cls,
default:
GNUNET_assert (0);
}
- GNUNET_CONTAINER_heap_update_cost (channel_heap,
- ts->heap_node,
+ GNUNET_CONTAINER_heap_update_cost (ts->heap_node,
GNUNET_TIME_absolute_get ().abs_value_us);
GNUNET_CADET_receive_done (channel);
return GNUNET_OK;
@@ -2361,8 +2358,7 @@ receive_tcp_back (void *cls,
}
break;
}
- GNUNET_CONTAINER_heap_update_cost (channel_heap,
- ts->heap_node,
+ GNUNET_CONTAINER_heap_update_cost (ts->heap_node,
GNUNET_TIME_absolute_get ().abs_value_us);
GNUNET_CADET_receive_done (channel);
return GNUNET_OK;
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: simplify GNUNET_CONTAINER_heap_update_cost API,
gnunet <=