aboutsummaryrefslogtreecommitdiff
path: root/src/gnunet_chat_context.c
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2021-10-31 18:20:05 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2021-10-31 18:20:05 +0100
commit5a08e8a921163dc0dcd57d73e6ce76b98e5cc29e (patch)
treece4d162423553bc5bdc1a085b7fca9a9ad811e27 /src/gnunet_chat_context.c
parentaa9014fd46c64142fb087d7a7288f5347532e2fe (diff)
downloadlibgnunetchat-5a08e8a921163dc0dcd57d73e6ce76b98e5cc29e.tar.gz
libgnunetchat-5a08e8a921163dc0dcd57d73e6ce76b98e5cc29e.zip
Added assertions to ensure code safety
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/gnunet_chat_context.c')
-rw-r--r--src/gnunet_chat_context.c16
1 files changed, 16 insertions, 0 deletions
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*
32context_create_from_room (struct GNUNET_CHAT_Handle *handle, 32context_create_from_room (struct GNUNET_CHAT_Handle *handle,
33 struct GNUNET_MESSENGER_Room *room) 33 struct GNUNET_MESSENGER_Room *room)
34{ 34{
35 GNUNET_assert((handle) && (room));
36
35 struct GNUNET_CHAT_Context* context = GNUNET_new(struct GNUNET_CHAT_Context); 37 struct GNUNET_CHAT_Context* context = GNUNET_new(struct GNUNET_CHAT_Context);
36 38
37 context->handle = handle; 39 context->handle = handle;
@@ -54,6 +56,12 @@ context_create_from_room (struct GNUNET_CHAT_Handle *handle,
54void 56void
55context_destroy (struct GNUNET_CHAT_Context* context) 57context_destroy (struct GNUNET_CHAT_Context* context)
56{ 58{
59 GNUNET_assert((context) &&
60 (context->timestamps) &&
61 (context->messages) &&
62 (context->invites) &&
63 (context->files));
64
57 GNUNET_CONTAINER_multishortmap_iterate( 65 GNUNET_CONTAINER_multishortmap_iterate(
58 context->timestamps, it_destroy_context_timestamps, NULL 66 context->timestamps, it_destroy_context_timestamps, NULL
59 ); 67 );
@@ -80,6 +88,10 @@ context_destroy (struct GNUNET_CHAT_Context* context)
80void 88void
81context_load_config (struct GNUNET_CHAT_Context *context) 89context_load_config (struct GNUNET_CHAT_Context *context)
82{ 90{
91 GNUNET_assert((context) &&
92 (context->handle) &&
93 (context->room));
94
83 const char *directory = context->handle->directory; 95 const char *directory = context->handle->directory;
84 96
85 if (!directory) 97 if (!directory)
@@ -119,6 +131,10 @@ free_filename:
119void 131void
120context_save_config (const struct GNUNET_CHAT_Context *context) 132context_save_config (const struct GNUNET_CHAT_Context *context)
121{ 133{
134 GNUNET_assert((context) &&
135 (context->handle) &&
136 (context->room));
137
122 const char *directory = context->handle->directory; 138 const char *directory = context->handle->directory;
123 139
124 if (!directory) 140 if (!directory)