From b39b0fed6860f296926ec68b9247e8ff8323ad51 Mon Sep 17 00:00:00 2001 From: Kolja Waschk Date: Sun, 10 Feb 2008 21:06:11 +0000 Subject: [PATCH] Correct update of q->next_item after moving data in resized queue (re: 1884952) git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1005 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/src/tap/cable.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jtag/src/tap/cable.c b/jtag/src/tap/cable.c index 6a63acc8..15c0c3d0 100644 --- a/jtag/src/tap/cable.c +++ b/jtag/src/tap/cable.c @@ -40,7 +40,7 @@ #include "jtag.h" #include "cable.h" -#undef VERBOSE +#undef VERBOSE extern cable_driver_t arcom_cable_driver; extern cable_driver_t byteblaster_cable_driver; @@ -203,14 +203,16 @@ cable_add_queue_item( cable_t *cable, cable_queue_info_t *q ) { /* Move queue items at end of old array * towards end of new array: 345612__ -> 3456__12 */ + + int dest = new_max_items - num_to_move; #ifdef VERBOSE printf("Resize: Move %d items towards end of queue memory (%d > %d)\n", - num_to_move, q->next_item, new_max_items - num_to_move); + num_to_move, q->next_item, dest); #endif - memmove(&(q->data[new_max_items - num_to_move]), &(q->data[q->next_item]), + memmove(&(q->data[dest]), &(q->data[q->next_item]), num_to_move * sizeof(cable_queue_t)); - q->next_item += num_to_move; + q->next_item = dest; } #ifdef CHOOSE_SMALLEST_AREA_TO_MOVE else