tcl/target|board: add config Atheros ar9331
[fw/openocd] / src / jtag / commands.c
index d2106da0257eb64e28e723c34f1663fa1ea23a03..5e06840a693680a5604cf4e06ea10abf166b5a3a 100644 (file)
@@ -109,14 +109,16 @@ void *cmd_queue_alloc(size_t size)
        if (!*p_page) {
                *p_page = malloc(sizeof(struct cmd_queue_page));
                (*p_page)->used = 0;
-               (*p_page)->address = malloc(CMD_QUEUE_PAGE_SIZE);
+               size_t alloc_size = (size < CMD_QUEUE_PAGE_SIZE) ?
+                                       CMD_QUEUE_PAGE_SIZE : size;
+               (*p_page)->address = malloc(alloc_size);
                (*p_page)->next = NULL;
        }
 
        offset = (*p_page)->used;
        (*p_page)->used += size;
 
-       t = (uint8_t *)((*p_page)->address);
+       t = (*p_page)->address;
        return t + offset;
 }