Skip to content

Commit

Permalink
jq_util_input_init: Zero memory using calloc
Browse files Browse the repository at this point in the history
Calloc will zero the allocated memory which makes one memset and a
number of explicit zero assignments redundant.
  • Loading branch information
orzen authored and nicowilliams committed Apr 4, 2019
1 parent 4f58a59 commit 263e106
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,11 @@ jq_util_input_state *jq_util_input_init(jq_util_msg_cb err_cb, void *err_cb_data
err_cb = fprinter;
err_cb_data = stderr;
}
jq_util_input_state *new_state = jv_mem_alloc(sizeof(*new_state));
memset(new_state, 0, sizeof(*new_state));
jq_util_input_state *new_state = jv_mem_calloc(1, sizeof(*new_state));
new_state->err_cb = err_cb;
new_state->err_cb_data = err_cb_data;
new_state->parser = NULL;
new_state->current_input = NULL;
new_state->files = NULL;
new_state->nfiles = 0;
new_state->curr_file = 0;
new_state->slurped = jv_invalid();
new_state->buf[0] = 0;
new_state->buf_valid_len = 0;
new_state->current_filename = jv_invalid();
new_state->current_line = 0;

return new_state;
}
Expand Down

0 comments on commit 263e106

Please sign in to comment.