libgnunetchat

library for GNUnet Messenger
Log | Files | Refs | README | LICENSE

commit e0394f3e292a6b828bc2e9c974aa1551c5e45850
parent 9d04b7c3981d1e0d25655dcb047c876dd5b275f6
Author: Jacki <jacki@thejackimonster.de>
Date:   Sat, 10 Feb 2024 06:45:26 +0100

Reduce allocations for rejections and fix deleted messages

Signed-off-by: Jacki <jacki@thejackimonster.de>

Diffstat:
Msrc/gnunet_chat_context.c | 5+----
Msrc/gnunet_chat_context_intern.c | 12------------
Msrc/gnunet_chat_handle_intern.c | 18++++++------------
3 files changed, 7 insertions(+), 28 deletions(-)

diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c @@ -126,10 +126,7 @@ context_destroy (struct GNUNET_CHAT_Context *context) context->messages, it_destroy_context_messages, NULL ); - GNUNET_CONTAINER_multihashmap_iterate( - context->rejections, it_destroy_context_rejections, NULL - ); - + GNUNET_CONTAINER_multihashmap_clear(context->rejections); GNUNET_CONTAINER_multihashmap_iterate( context->invites, it_destroy_context_invites, NULL ); diff --git a/src/gnunet_chat_context_intern.c b/src/gnunet_chat_context_intern.c @@ -55,18 +55,6 @@ it_destroy_context_messages (GNUNET_UNUSED void *cls, } int -it_destroy_context_rejections (GNUNET_UNUSED void *cls, - GNUNET_UNUSED const struct GNUNET_HashCode *key, - void *value) -{ - GNUNET_assert(value); - - struct GNUNET_HashCode *hash = value; - GNUNET_free(hash); - return GNUNET_YES; -} - -int it_destroy_context_invites (GNUNET_UNUSED void *cls, GNUNET_UNUSED const struct GNUNET_HashCode *key, void *value) diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c @@ -772,13 +772,15 @@ on_handle_message_callback(void *cls) GNUNET_assert( (message) && - (message->msg) && (message->context) && (message->context->handle) ); message->task = NULL; + if (! message->msg) + return; + struct GNUNET_CHAT_Context *context = message->context; struct GNUNET_CHAT_Handle *handle = context->handle; @@ -1004,17 +1006,9 @@ on_handle_message (void *cls, if (msg->body.tag.tag) break; - struct GNUNET_HashCode *rejection = GNUNET_new(struct GNUNET_HashCode); - - if (!rejection) - break; - - GNUNET_memcpy(rejection, hash, sizeof(struct GNUNET_HashCode)); - - if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put( - context->rejections, &(msg->body.tag.hash), rejection, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)) - GNUNET_free (rejection); + GNUNET_CONTAINER_multihashmap_put( + context->rejections, &(msg->body.tag.hash), + message, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); break; }