summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2013-05-15 11:35:47 +0000
committerFlorian Dold <florian.dold@gmail.com>2013-05-15 11:35:47 +0000
commit342eb75d669cc3afa641ee926c4d01f50699b205 (patch)
tree11f52a441d54ac2be1c5c7be9e245a6bdf8bd81d /src
parent6f54b50858457dfa2b5f0b519fbf230e1119c6b2 (diff)
removed unnecessary malloc
Diffstat (limited to 'src')
-rw-r--r--src/set/gnunet-service-set.c5
-rw-r--r--src/set/gnunet-service-set_union.c31
2 files changed, 34 insertions, 2 deletions
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c
index 3ed896775..9ac0fbee6 100644
--- a/src/set/gnunet-service-set.c
+++ b/src/set/gnunet-service-set.c
@@ -324,7 +324,7 @@ handle_client_create (void *cls,
return;
}
- set = GNUNET_new (struct Set);
+ set = NULL;
switch (ntohs (msg->operation))
{
@@ -336,12 +336,13 @@ handle_client_create (void *cls,
set = _GSS_union_set_create ();
break;
default:
- GNUNET_free (set);
GNUNET_break (0);
GNUNET_SERVER_client_disconnect (client);
return;
}
+ GNUNET_assert (NULL != set);
+
set->client = client;
GNUNET_SERVER_client_keep (client);
set->client_mq = GNUNET_MQ_queue_for_server_client (client);
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index 694fb6056..05b125047 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -364,6 +364,34 @@ destroy_elements (struct UnionState *us)
}
+
+/**
+ * Iterator over hash map entries.
+ *
+ * @param cls closure
+ * @param key current key code
+ * @param value value in the hash map
+ * @return GNUNET_YES if we should continue to
+ * iterate,
+ * GNUNET_NO if not.
+ */
+static int
+destroy_key_to_element_iter (void *cls,
+ uint32_t key,
+ void *value)
+{
+ struct KeyEntry *k = value;
+
+ while (NULL != k)
+ {
+ struct KeyEntry *k_tmp = k;
+ k = k->next_colliding;
+ GNUNET_free (k_tmp);
+ }
+ return GNUNET_YES;
+}
+
+
/**
* Destroy a union operation, and free all resources
* associated with it.
@@ -400,6 +428,7 @@ destroy_union_operation (struct UnionEvaluateOperation *eo)
}
if (NULL != eo->key_to_element)
{
+ GNUNET_CONTAINER_multihashmap32_iterate (eo->key_to_element, destroy_key_to_element_iter, NULL);
GNUNET_CONTAINER_multihashmap32_destroy (eo->key_to_element);
eo->key_to_element = NULL;
}
@@ -1030,6 +1059,8 @@ handle_p2p_elements (void *cls, const struct GNUNET_MessageHeader *mh)
insert_element (eo, ee);
send_client_element (eo, &ee->element);
+
+ GNUNET_free (ee);
}