jtag/tcl: Remove no-op free 66/1666/2
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>
Sat, 28 Sep 2013 14:29:50 +0000 (16:29 +0200)
committerSpencer Oliver <spen@spen-soft.co.uk>
Mon, 7 Oct 2013 19:03:18 +0000 (19:03 +0000)
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>
src/jtag/tcl.c

index 227222e..fb060f9 100644 (file)
@@ -1120,17 +1120,12 @@ COMMAND_HANDLER(handle_irscan_command)
                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]);