Skip to content
Myr

jq_util_input_init: Zero memory using calloc

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Calloc will zero the allocated memory which makes one memset and a number of explicit zero assignments redundant.

authored by Mattias Hansson · committed by Nico Williams · parent 4f58a59 · Browse files · 1 file+1 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+1 added−10 removed

  • other:+1 added−10 removed

1 file+1 added−10 removed

modified:src/util.c+1 added-10 removed
206 unmodified lines
207 if (err_cb == NULL) {208 err_cb = fprinter;209 err_cb_data = stderr;210 }211 jq_util_input_state *new_state = jv_mem_alloc(sizeof(*new_state));212 memset(new_state, 0, sizeof(*new_state));211 jq_util_input_state *new_state = jv_mem_calloc(1, sizeof(*new_state));212 new_state->err_cb = err_cb;213 new_state->err_cb_data = err_cb_data;215 new_state->parser = NULL;216 new_state->current_input = NULL;217 new_state->files = NULL;218 new_state->nfiles = 0;219 new_state->curr_file = 0;214 new_state->slurped = jv_invalid();221 new_state->buf[0] = 0;222 new_state->buf_valid_len = 0;215 new_state->current_filename = jv_invalid();224 new_state->current_line = 0;216217 return new_state;218}219
239 unmodified lines