1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Reduce codelines in form.c

Let's use calloc instead of malloc and then setting almost all fields to
NULL.
This commit is contained in:
Michael Vetter 2019-07-10 12:53:45 +02:00
parent a8b3de7016
commit 6c8e567328

View File

@ -82,14 +82,7 @@ _is_valid_form_element(xmpp_stanza_t *stanza)
static DataForm* static DataForm*
_form_new(void) _form_new(void)
{ {
DataForm *form = malloc(sizeof(DataForm)); DataForm *form = calloc(1, 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;
return form; return form;
} }
@ -97,14 +90,7 @@ _form_new(void)
static FormField* static FormField*
_field_new(void) _field_new(void)
{ {
FormField *field = malloc(sizeof(FormField)); FormField *field = calloc(1, sizeof(FormField));
field->label = NULL;
field->type = NULL;
field->var = NULL;
field->description = NULL;
field->required = FALSE;
field->values = NULL;
field->options = NULL;
return field; return field;
} }