And use calloc instead of malloc+memset.
Change-Id: Icc1ed6e34904972bb5d3728307dcae5c55b32fc3
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1666
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
return ERROR_COMMAND_SYNTAX_ERROR;
}
- size_t fields_len = sizeof(struct scan_field) * num_fields;
- fields = malloc(fields_len);
- memset(fields, 0, fields_len);
+ fields = calloc(num_fields, sizeof(*fields));
int retval;
for (i = 0; i < num_fields; i++) {
tap = jtag_tap_by_string(CMD_ARGV[i*2]);
if (tap == NULL) {
- int j;
- for (j = 0; j < i; j++)
- free((void *)fields[j].out_value);
free(fields);
command_print(CMD_CTX, "Tap: %s unknown", CMD_ARGV[i*2]);