diff options
-rw-r--r-- | src/piece-table.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/piece-table.c b/src/piece-table.c index e869ae2..6db05d7 100644 --- a/src/piece-table.c +++ b/src/piece-table.c @@ -71,7 +71,7 @@ static void free_piece_list(piece *p) { assert(p != NULL); for ( cur = p->next; cur != p; cur = next ) { next = cur->next; - free( cur ); + free(cur); } free(cur); } @@ -151,14 +151,14 @@ void delete_piece_table(piece_table *pt, size_t pos, size_t len) { piece *cur, *next, *start, *end; assert( pos + len <= pt->length ); - if ( pos == 0) { + if ( pos == 0 ) { start = pt->sentinel; } else { find_piece_by_pos(pt, pos); start = split_piece(pt->cached, pos - pt->cached_offset); } - if (pos + len == pt->length) { + if ( pos + len == pt->length ) { end = pt->sentinel; } else { find_piece_by_pos(pt, pos + len); @@ -170,6 +170,7 @@ void delete_piece_table(piece_table *pt, size_t pos, size_t len) { next = cur->next; free(cur); } + start->next = end; end->prev = start; pt->length -= len; |