From 5a08e8a921163dc0dcd57d73e6ce76b98e5cc29e Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Sun, 31 Oct 2021 18:20:05 +0100 Subject: Added assertions to ensure code safety Signed-off-by: TheJackiMonster --- src/gnunet_chat_context.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/gnunet_chat_context.c') diff --git a/src/gnunet_chat_context.c b/src/gnunet_chat_context.c index 06f9c88..458063f 100644 --- a/src/gnunet_chat_context.c +++ b/src/gnunet_chat_context.c @@ -32,6 +32,8 @@ struct GNUNET_CHAT_Context* context_create_from_room (struct GNUNET_CHAT_Handle *handle, struct GNUNET_MESSENGER_Room *room) { + GNUNET_assert((handle) && (room)); + struct GNUNET_CHAT_Context* context = GNUNET_new(struct GNUNET_CHAT_Context); context->handle = handle; @@ -54,6 +56,12 @@ context_create_from_room (struct GNUNET_CHAT_Handle *handle, void context_destroy (struct GNUNET_CHAT_Context* context) { + GNUNET_assert((context) && + (context->timestamps) && + (context->messages) && + (context->invites) && + (context->files)); + GNUNET_CONTAINER_multishortmap_iterate( context->timestamps, it_destroy_context_timestamps, NULL ); @@ -80,6 +88,10 @@ context_destroy (struct GNUNET_CHAT_Context* context) void context_load_config (struct GNUNET_CHAT_Context *context) { + GNUNET_assert((context) && + (context->handle) && + (context->room)); + const char *directory = context->handle->directory; if (!directory) @@ -119,6 +131,10 @@ free_filename: void context_save_config (const struct GNUNET_CHAT_Context *context) { + GNUNET_assert((context) && + (context->handle) && + (context->room)); + const char *directory = context->handle->directory; if (!directory) -- cgit v1.2.3