about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-07-10 12:53:45 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-07-10 12:53:45 +0200
commit6c8e567328818be9cda03393445554ef76f636c5 (patch)
tree56234d163f3f0b8b5172ad9111e7159c0b054e8e /src
parenta8b3de7016dddb1032988ee801eb621a311b0a0f (diff)
downloadprofani-tty-6c8e567328818be9cda03393445554ef76f636c5.tar.gz
Reduce codelines in form.c
Let's use calloc instead of malloc and then setting almost all fields to
NULL.
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/form.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/xmpp/form.c b/src/xmpp/form.c
index d30eb0fc..d0b9feac 100644
--- a/src/xmpp/form.c
+++ b/src/xmpp/form.c
@@ -82,14 +82,7 @@ _is_valid_form_element(xmpp_stanza_t *stanza)
 static DataForm*
 _form_new(void)
 {
-    DataForm *form = malloc(sizeof(DataForm));
-    form->type = NULL;
-    form->title = NULL;
-    form->instructions = NULL;
-    form->fields = NULL;
-    form->var_to_tag = NULL;
-    form->tag_to_var = NULL;
-    form->tag_ac = NULL;
+    DataForm *form = calloc(1, sizeof(DataForm));
 
     return form;
 }
@@ -97,14 +90,7 @@ _form_new(void)
 static FormField*
 _field_new(void)
 {
-    FormField *field = malloc(sizeof(FormField));
-    field->label = NULL;
-    field->type = NULL;
-    field->var = NULL;
-    field->description = NULL;
-    field->required = FALSE;
-    field->values = NULL;
-    field->options = NULL;
+    FormField *field = calloc(1, sizeof(FormField));
 
     return field;
 }