for_each_hash: allow passing a 'void *data' pointer to callback
[git/git.git] / diffcore-rename.c
CommitLineData
427dcb4b
JH
1/*
2 * Copyright (C) 2005 Junio C Hamano
3 */
4#include "cache.h"
5#include "diff.h"
6#include "diffcore.h"
9027f53c 7#include "hash.h"
427dcb4b 8
25d5ea41
JH
9/* Table of rename/copy destinations */
10
11static struct diff_rename_dst {
12 struct diff_filespec *two;
13 struct diff_filepair *pair;
14} *rename_dst;
15static int rename_dst_nr, rename_dst_alloc;
427dcb4b 16
25d5ea41
JH
17static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,
18 int insert_ok)
427dcb4b 19{
25d5ea41
JH
20 int first, last;
21
22 first = 0;
23 last = rename_dst_nr;
24 while (last > first) {
25 int next = (last + first) >> 1;
26 struct diff_rename_dst *dst = &(rename_dst[next]);
27 int cmp = strcmp(two->path, dst->two->path);
28 if (!cmp)
29 return dst;
30 if (cmp < 0) {
31 last = next;
32 continue;
33 }
34 first = next+1;
35 }
36 /* not found */
37 if (!insert_ok)
38 return NULL;
39 /* insert to make it at "first" */
40 if (rename_dst_alloc <= rename_dst_nr) {
41 rename_dst_alloc = alloc_nr(rename_dst_alloc);
42 rename_dst = xrealloc(rename_dst,
43 rename_dst_alloc * sizeof(*rename_dst));
44 }
45 rename_dst_nr++;
46 if (first < rename_dst_nr)
47 memmove(rename_dst + first + 1, rename_dst + first,
48 (rename_dst_nr - first - 1) * sizeof(*rename_dst));
5098bafb
JH
49 rename_dst[first].two = alloc_filespec(two->path);
50 fill_filespec(rename_dst[first].two, two->sha1, two->mode);
25d5ea41
JH
51 rename_dst[first].pair = NULL;
52 return &(rename_dst[first]);
427dcb4b
JH
53}
54
15d061b4 55/* Table of rename/copy src files */
25d5ea41
JH
56static struct diff_rename_src {
57 struct diff_filespec *one;
fc580719 58 unsigned short score; /* to remember the break score */
25d5ea41
JH
59} *rename_src;
60static int rename_src_nr, rename_src_alloc;
427dcb4b 61
15d061b4 62static struct diff_rename_src *register_rename_src(struct diff_filespec *one,
fc580719 63 unsigned short score)
25d5ea41
JH
64{
65 int first, last;
66
67 first = 0;
68 last = rename_src_nr;
69 while (last > first) {
70 int next = (last + first) >> 1;
71 struct diff_rename_src *src = &(rename_src[next]);
72 int cmp = strcmp(one->path, src->one->path);
73 if (!cmp)
74 return src;
75 if (cmp < 0) {
76 last = next;
77 continue;
78 }
79 first = next+1;
80 }
15d061b4 81
25d5ea41
JH
82 /* insert to make it at "first" */
83 if (rename_src_alloc <= rename_src_nr) {
84 rename_src_alloc = alloc_nr(rename_src_alloc);
85 rename_src = xrealloc(rename_src,
86 rename_src_alloc * sizeof(*rename_src));
427dcb4b 87 }
25d5ea41
JH
88 rename_src_nr++;
89 if (first < rename_src_nr)
90 memmove(rename_src + first + 1, rename_src + first,
91 (rename_src_nr - first - 1) * sizeof(*rename_src));
92 rename_src[first].one = one;
fc580719 93 rename_src[first].score = score;
25d5ea41 94 return &(rename_src[first]);
427dcb4b
JH
95}
96
0ce39643
JS
97static int basename_same(struct diff_filespec *src, struct diff_filespec *dst)
98{
99 int src_len = strlen(src->path), dst_len = strlen(dst->path);
100 while (src_len && dst_len) {
101 char c1 = src->path[--src_len];
102 char c2 = dst->path[--dst_len];
103 if (c1 != c2)
104 return 0;
105 if (c1 == '/')
106 return 1;
107 }
108 return (!src_len || src->path[src_len - 1] == '/') &&
109 (!dst_len || dst->path[dst_len - 1] == '/');
110}
111
427dcb4b 112struct diff_score {
25d5ea41
JH
113 int src; /* index in rename_src */
114 int dst; /* index in rename_dst */
6d24ad97
JH
115 unsigned short score;
116 short name_score;
427dcb4b
JH
117};
118
119static int estimate_similarity(struct diff_filespec *src,
120 struct diff_filespec *dst,
121 int minimum_score)
122{
123 /* src points at a file that existed in the original tree (or
124 * optionally a file in the destination tree) and dst points
125 * at a newly created file. They may be quite similar, in which
126 * case we want to say src is renamed to dst or src is copied into
127 * dst, and then some edit has been applied to dst.
128 *
129 * Compare them and return how similar they are, representing
f0c6b2a2
JH
130 * the score as an integer between 0 and MAX_SCORE.
131 *
132 * When there is an exact match, it is considered a better
133 * match than anything else; the destination does not even
134 * call into this function in that case.
427dcb4b 135 */
90bd932c 136 unsigned long max_size, delta_size, base_size, src_copied, literal_added;
75c660ac 137 unsigned long delta_limit;
427dcb4b
JH
138 int score;
139
60896c7b
JH
140 /* We deal only with regular files. Symlink renames are handled
141 * only when they are exact matches --- in other words, no edits
142 * after renaming.
143 */
144 if (!S_ISREG(src->mode) || !S_ISREG(dst->mode))
145 return 0;
146
81ac051d
LT
147 /*
148 * Need to check that source and destination sizes are
149 * filled in before comparing them.
150 *
151 * If we already have "cnt_data" filled in, we know it's
152 * all good (avoid checking the size for zero, as that
153 * is a possible size - we really should have a flag to
154 * say whether the size is valid or not!)
155 */
885c716f 156 if (!src->cnt_data && diff_populate_filespec(src, 1))
81ac051d 157 return 0;
885c716f 158 if (!dst->cnt_data && diff_populate_filespec(dst, 1))
81ac051d
LT
159 return 0;
160
90bd932c 161 max_size = ((src->size > dst->size) ? src->size : dst->size);
58b103f5 162 base_size = ((src->size < dst->size) ? src->size : dst->size);
90bd932c 163 delta_size = max_size - base_size;
427dcb4b 164
58b103f5
JH
165 /* We would not consider edits that change the file size so
166 * drastically. delta_size must be smaller than
cd1870ed 167 * (MAX_SCORE-minimum_score)/MAX_SCORE * min(src->size, dst->size).
f0c6b2a2 168 *
58b103f5
JH
169 * Note that base_size == 0 case is handled here already
170 * and the final score computation below would not have a
171 * divide-by-zero issue.
427dcb4b 172 */
cd1870ed 173 if (base_size * (MAX_SCORE-minimum_score) < delta_size * MAX_SCORE)
427dcb4b
JH
174 return 0;
175
885c716f
BS
176 if (!src->cnt_data && diff_populate_filespec(src, 0))
177 return 0;
178 if (!dst->cnt_data && diff_populate_filespec(dst, 0))
179 return 0;
180
dc49cd76
SP
181 delta_limit = (unsigned long)
182 (base_size * (MAX_SCORE-minimum_score) / MAX_SCORE);
d8c3d03a 183 if (diffcore_count_changes(src, dst,
c06c7966 184 &src->cnt_data, &dst->cnt_data,
65416758
JH
185 delta_limit,
186 &src_copied, &literal_added))
85976974 187 return 0;
355e76a4 188
1706306a
JH
189 /* How similar are they?
190 * what percentage of material in dst are from source?
427dcb4b 191 */
90bd932c 192 if (!dst->size)
1706306a 193 score = 0; /* should not happen */
cfc0aef1 194 else
dc49cd76 195 score = (int)(src_copied * MAX_SCORE / max_size);
427dcb4b
JH
196 return score;
197}
198
5098bafb 199static void record_rename_pair(int dst_index, int src_index, int score)
427dcb4b 200{
9fb88419 201 struct diff_filespec *src, *dst;
25d5ea41 202 struct diff_filepair *dp;
f7c1512a 203
25d5ea41
JH
204 if (rename_dst[dst_index].pair)
205 die("internal error: dst already matched.");
427dcb4b 206
25d5ea41 207 src = rename_src[src_index].one;
64479711 208 src->rename_used++;
9fb88419 209 src->count++;
427dcb4b 210
25d5ea41 211 dst = rename_dst[dst_index].two;
9fb88419 212 dst->count++;
427dcb4b 213
9fb88419 214 dp = diff_queue(NULL, src, dst);
ef677686 215 dp->renamed_pair = 1;
fc580719
JH
216 if (!strcmp(src->path, dst->path))
217 dp->score = rename_src[src_index].score;
218 else
219 dp->score = score;
25d5ea41 220 rename_dst[dst_index].pair = dp;
427dcb4b
JH
221}
222
223/*
224 * We sort the rename similarity matrix with the score, in descending
15d061b4 225 * order (the most similar first).
427dcb4b
JH
226 */
227static int score_compare(const void *a_, const void *b_)
228{
229 const struct diff_score *a = a_, *b = b_;
cfc0aef1 230
6d24ad97
JH
231 /* sink the unused ones to the bottom */
232 if (a->dst < 0)
233 return (0 <= b->dst);
234 else if (b->dst < 0)
235 return -1;
236
cfc0aef1
RS
237 if (a->score == b->score)
238 return b->name_score - a->name_score;
239
427dcb4b
JH
240 return b->score - a->score;
241}
242
9027f53c
LT
243struct file_similarity {
244 int src_dst, index;
245 struct diff_filespec *filespec;
246 struct file_similarity *next;
247};
248
249static int find_identical_files(struct file_similarity *src,
11f944dd
LT
250 struct file_similarity *dst,
251 struct diff_options *options)
9027f53c
LT
252{
253 int renames = 0;
254
255 /*
256 * Walk over all the destinations ...
257 */
258 do {
32d75d29 259 struct diff_filespec *target = dst->filespec;
9027f53c 260 struct file_similarity *p, *best;
32d75d29 261 int i = 100, best_score = -1;
9027f53c
LT
262
263 /*
264 * .. to find the best source match
265 */
266 best = NULL;
267 for (p = src; p; p = p->next) {
32d75d29
LT
268 int score;
269 struct diff_filespec *source = p->filespec;
9027f53c 270
3ea3c215 271 /* False hash collision? */
32d75d29 272 if (hashcmp(source->sha1, target->sha1))
9027f53c
LT
273 continue;
274 /* Non-regular files? If so, the modes must match! */
32d75d29
LT
275 if (!S_ISREG(source->mode) || !S_ISREG(target->mode)) {
276 if (source->mode != target->mode)
9027f53c
LT
277 continue;
278 }
32d75d29
LT
279 /* Give higher scores to sources that haven't been used already */
280 score = !source->rename_used;
281 score += basename_same(source, target);
282 if (score > best_score) {
283 best = p;
284 best_score = score;
285 if (score == 2)
286 break;
287 }
9027f53c
LT
288
289 /* Too many identical alternatives? Pick one */
290 if (!--i)
291 break;
292 }
293 if (best) {
294 record_rename_pair(dst->index, best->index, MAX_SCORE);
295 renames++;
296 }
297 } while ((dst = dst->next) != NULL);
298 return renames;
299}
300
9027f53c
LT
301static void free_similarity_list(struct file_similarity *p)
302{
303 while (p) {
304 struct file_similarity *entry = p;
305 p = p->next;
9027f53c
LT
306 free(entry);
307 }
308}
309
11f944dd 310static int find_same_files(void *ptr, void *data)
9027f53c
LT
311{
312 int ret;
313 struct file_similarity *p = ptr;
314 struct file_similarity *src = NULL, *dst = NULL;
11f944dd 315 struct diff_options *options = data;
9027f53c
LT
316
317 /* Split the hash list up into sources and destinations */
318 do {
319 struct file_similarity *entry = p;
320 p = p->next;
321 if (entry->src_dst < 0) {
322 entry->next = src;
323 src = entry;
324 } else {
325 entry->next = dst;
326 dst = entry;
327 }
328 } while (p);
329
330 /*
331 * If we have both sources *and* destinations, see if
332 * we can match them up
333 */
11f944dd 334 ret = (src && dst) ? find_identical_files(src, dst, options) : 0;
9027f53c
LT
335
336 /* Free the hashes and return the number of renames found */
337 free_similarity_list(src);
338 free_similarity_list(dst);
339 return ret;
340}
341
342static unsigned int hash_filespec(struct diff_filespec *filespec)
343{
344 unsigned int hash;
345 if (!filespec->sha1_valid) {
346 if (diff_populate_filespec(filespec, 0))
347 return 0;
348 hash_sha1_file(filespec->data, filespec->size, "blob", filespec->sha1);
349 }
350 memcpy(&hash, filespec->sha1, sizeof(hash));
351 return hash;
352}
353
354static void insert_file_table(struct hash_table *table, int src_dst, int index, struct diff_filespec *filespec)
355{
356 void **pos;
357 unsigned int hash;
358 struct file_similarity *entry = xmalloc(sizeof(*entry));
359
360 entry->src_dst = src_dst;
361 entry->index = index;
362 entry->filespec = filespec;
363 entry->next = NULL;
364
365 hash = hash_filespec(filespec);
366 pos = insert_hash(hash, entry, table);
367
368 /* We already had an entry there? */
369 if (pos) {
370 entry->next = *pos;
371 *pos = entry;
372 }
373}
374
cb1491b6
LT
375/*
376 * Find exact renames first.
377 *
378 * The first round matches up the up-to-date entries,
379 * and then during the second round we try to match
380 * cache-dirty entries as well.
cb1491b6 381 */
11f944dd 382static int find_exact_renames(struct diff_options *options)
cb1491b6 383{
9027f53c
LT
384 int i;
385 struct hash_table file_table;
cb1491b6 386
9027f53c
LT
387 init_hash(&file_table);
388 for (i = 0; i < rename_src_nr; i++)
389 insert_file_table(&file_table, -1, i, rename_src[i].one);
390
391 for (i = 0; i < rename_dst_nr; i++)
392 insert_file_table(&file_table, 1, i, rename_dst[i].two);
393
394 /* Find the renames */
11f944dd 395 i = for_each_hash(&file_table, find_same_files, options);
9027f53c
LT
396
397 /* .. and free the hash data structure */
398 free_hash(&file_table);
399
400 return i;
cb1491b6
LT
401}
402
6d24ad97
JH
403#define NUM_CANDIDATE_PER_DST 4
404static void record_if_better(struct diff_score m[], struct diff_score *o)
405{
406 int i, worst;
407
408 /* find the worst one */
409 worst = 0;
410 for (i = 1; i < NUM_CANDIDATE_PER_DST; i++)
411 if (score_compare(&m[i], &m[worst]) > 0)
412 worst = i;
413
414 /* is it better than the worst one? */
415 if (score_compare(&m[worst], o) > 0)
416 m[worst] = *o;
417}
418
8082d8d3 419void diffcore_rename(struct diff_options *options)
427dcb4b 420{
8082d8d3
JH
421 int detect_rename = options->detect_rename;
422 int minimum_score = options->rename_score;
423 int rename_limit = options->rename_limit;
38c6f780 424 struct diff_queue_struct *q = &diff_queued_diff;
5098bafb 425 struct diff_queue_struct outq;
427dcb4b 426 struct diff_score *mx;
cb1491b6 427 int i, j, rename_count;
25d5ea41 428 int num_create, num_src, dst_cnt;
427dcb4b 429
26dee0ad 430 if (!minimum_score)
f345b0a0 431 minimum_score = DEFAULT_RENAME_SCORE;
427dcb4b 432
427dcb4b 433 for (i = 0; i < q->nr; i++) {
52e95789 434 struct diff_filepair *p = q->queue[i];
2f3f8b21 435 if (!DIFF_FILE_VALID(p->one)) {
81e50eab 436 if (!DIFF_FILE_VALID(p->two))
60896c7b 437 continue; /* unmerged */
2f3f8b21
JH
438 else if (options->single_follow &&
439 strcmp(options->single_follow, p->two->path))
440 continue; /* not interested */
427dcb4b 441 else
25d5ea41 442 locate_rename_dst(p->two, 1);
2f3f8b21 443 }
2210100a 444 else if (!DIFF_FILE_VALID(p->two)) {
64479711
LT
445 /*
446 * If the source is a broken "delete", and
2210100a
JH
447 * they did not really want to get broken,
448 * that means the source actually stays.
64479711
LT
449 * So we increment the "rename_used" score
450 * by one, to indicate ourselves as a user
451 */
452 if (p->broken_pair && !p->score)
453 p->one->rename_used++;
454 register_rename_src(p->one, p->score);
455 }
456 else if (detect_rename == DIFF_DETECT_COPY) {
457 /*
458 * Increment the "rename_used" score by
459 * one, to indicate ourselves as a user.
2210100a 460 */
64479711
LT
461 p->one->rename_used++;
462 register_rename_src(p->one, p->score);
2210100a 463 }
427dcb4b 464 }
0024a549 465 if (rename_dst_nr == 0 || rename_src_nr == 0)
427dcb4b
JH
466 goto cleanup; /* nothing to do */
467
17559a64
LT
468 /*
469 * We really want to cull the candidates list early
470 * with cheap tests in order to avoid doing deltas.
471 */
11f944dd 472 rename_count = find_exact_renames(options);
17559a64 473
42899ac8
LT
474 /* Did we only want exact renames? */
475 if (minimum_score == MAX_SCORE)
476 goto cleanup;
477
478 /*
479 * Calculate how many renames are left (but all the source
480 * files still remain as options for rename/copies!)
481 */
482 num_create = (rename_dst_nr - rename_count);
483 num_src = rename_src_nr;
484
485 /* All done? */
486 if (!num_create)
487 goto cleanup;
488
0024a549
LT
489 /*
490 * This basically does a test for the rename matrix not
491 * growing larger than a "rename_limit" square matrix, ie:
492 *
42899ac8 493 * num_create * num_src > rename_limit * rename_limit
0024a549
LT
494 *
495 * but handles the potential overflow case specially (and we
496 * assume at least 32-bit integers)
497 */
498 if (rename_limit <= 0 || rename_limit > 32767)
499 rename_limit = 32767;
ee542ee3
JK
500 if ((num_create > rename_limit && num_src > rename_limit) ||
501 (num_create * num_src > rename_limit * rename_limit)) {
b8960bbe 502 if (options->warn_on_too_large_rename)
6e381d3a 503 warning("too many files (created: %d deleted: %d), skipping inexact rename detection", num_create, num_src);
0024a549 504 goto cleanup;
ee542ee3 505 }
0024a549 506
6d24ad97 507 mx = xcalloc(num_create * NUM_CANDIDATE_PER_DST, sizeof(*mx));
25d5ea41 508 for (dst_cnt = i = 0; i < rename_dst_nr; i++) {
25d5ea41 509 struct diff_filespec *two = rename_dst[i].two;
6d24ad97
JH
510 struct diff_score *m;
511
25d5ea41 512 if (rename_dst[i].pair)
427dcb4b 513 continue; /* dealt with exact match already. */
6d24ad97
JH
514
515 m = &mx[dst_cnt * NUM_CANDIDATE_PER_DST];
516 for (j = 0; j < NUM_CANDIDATE_PER_DST; j++)
517 m[j].dst = -1;
518
25d5ea41
JH
519 for (j = 0; j < rename_src_nr; j++) {
520 struct diff_filespec *one = rename_src[j].one;
6d24ad97
JH
521 struct diff_score this_src;
522 this_src.score = estimate_similarity(one, two,
523 minimum_score);
524 this_src.name_score = basename_same(one, two);
525 this_src.dst = i;
526 this_src.src = j;
527 record_if_better(m, &this_src);
809809bb
JH
528 /*
529 * Once we run estimate_similarity,
530 * We do not need the text anymore.
531 */
8ae92e63 532 diff_free_filespec_blob(one);
809809bb 533 diff_free_filespec_blob(two);
427dcb4b
JH
534 }
535 dst_cnt++;
536 }
6d24ad97 537
427dcb4b 538 /* cost matrix sorted by most to least similar pair */
6d24ad97
JH
539 qsort(mx, dst_cnt * NUM_CANDIDATE_PER_DST, sizeof(*mx), score_compare);
540
541 for (i = 0; i < dst_cnt * NUM_CANDIDATE_PER_DST; i++) {
542 struct diff_rename_dst *dst;
543
544 if ((mx[i].dst < 0) ||
545 (mx[i].score < minimum_score))
546 break; /* there is no more usable pair. */
547 dst = &rename_dst[mx[i].dst];
9ae8fcb3
LT
548 if (dst->pair)
549 continue; /* already done, either exact or fuzzy. */
6d24ad97 550 if (rename_src[mx[i].src].one->rename_used)
9ae8fcb3
LT
551 continue;
552 record_rename_pair(mx[i].dst, mx[i].src, mx[i].score);
553 rename_count++;
554 }
6d24ad97
JH
555
556 for (i = 0; i < dst_cnt * NUM_CANDIDATE_PER_DST; i++) {
557 struct diff_rename_dst *dst;
558
559 if ((mx[i].dst < 0) ||
560 (mx[i].score < minimum_score))
561 break; /* there is no more usable pair. */
562 dst = &rename_dst[mx[i].dst];
25d5ea41
JH
563 if (dst->pair)
564 continue; /* already done, either exact or fuzzy. */
5098bafb
JH
565 record_rename_pair(mx[i].dst, mx[i].src, mx[i].score);
566 rename_count++;
427dcb4b
JH
567 }
568 free(mx);
427dcb4b 569
15d061b4 570 cleanup:
427dcb4b 571 /* At this point, we have found some renames and copies and they
5098bafb 572 * are recorded in rename_dst. The original list is still in *q.
427dcb4b 573 */
9ca5df90 574 DIFF_QUEUE_CLEAR(&outq);
427dcb4b 575 for (i = 0; i < q->nr; i++) {
25d5ea41 576 struct diff_filepair *p = q->queue[i];
25d5ea41
JH
577 struct diff_filepair *pair_to_free = NULL;
578
2cd68882
JH
579 if (!DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two)) {
580 /*
581 * Creation
582 *
583 * We would output this create record if it has
584 * not been turned into a rename/copy already.
585 */
586 struct diff_rename_dst *dst =
587 locate_rename_dst(p->two, 0);
588 if (dst && dst->pair) {
25d5ea41
JH
589 diff_q(&outq, dst->pair);
590 pair_to_free = p;
591 }
592 else
2cd68882
JH
593 /* no matching rename/copy source, so
594 * record this as a creation.
25d5ea41
JH
595 */
596 diff_q(&outq, p);
427dcb4b 597 }
2cd68882
JH
598 else if (DIFF_FILE_VALID(p->one) && !DIFF_FILE_VALID(p->two)) {
599 /*
600 * Deletion
601 *
f345b0a0
JH
602 * We would output this delete record if:
603 *
604 * (1) this is a broken delete and the counterpart
605 * broken create remains in the output; or
5098bafb
JH
606 * (2) this is not a broken delete, and rename_dst
607 * does not have a rename/copy to move p->one->path
608 * out of existence.
f345b0a0
JH
609 *
610 * Otherwise, the counterpart broken create
611 * has been turned into a rename-edit; or
612 * delete did not have a matching create to
613 * begin with.
2cd68882 614 */
f345b0a0
JH
615 if (DIFF_PAIR_BROKEN(p)) {
616 /* broken delete */
617 struct diff_rename_dst *dst =
618 locate_rename_dst(p->one, 0);
619 if (dst && dst->pair)
620 /* counterpart is now rename/copy */
621 pair_to_free = p;
622 }
623 else {
64479711 624 if (p->one->rename_used)
f345b0a0
JH
625 /* this path remains */
626 pair_to_free = p;
627 }
2cd68882
JH
628
629 if (pair_to_free)
630 ;
631 else
632 diff_q(&outq, p);
633 }
25d5ea41 634 else if (!diff_unmodified_pair(p))
15d061b4 635 /* all the usual ones need to be kept */
25d5ea41 636 diff_q(&outq, p);
15d061b4
JH
637 else
638 /* no need to keep unmodified pairs */
639 pair_to_free = p;
640
226406f6
JH
641 if (pair_to_free)
642 diff_free_filepair(pair_to_free);
427dcb4b 643 }
25d5ea41 644 diff_debug_queue("done copying original", &outq);
427dcb4b 645
25d5ea41
JH
646 free(q->queue);
647 *q = outq;
648 diff_debug_queue("done collapsing", q);
427dcb4b 649
9fb88419
LT
650 for (i = 0; i < rename_dst_nr; i++)
651 free_filespec(rename_dst[i].two);
5098bafb 652
25d5ea41
JH
653 free(rename_dst);
654 rename_dst = NULL;
655 rename_dst_nr = rename_dst_alloc = 0;
656 free(rename_src);
657 rename_src = NULL;
658 rename_src_nr = rename_src_alloc = 0;
427dcb4b
JH
659 return;
660}