| 1054 | }; |
| 1055 | |
| 1056 | static struct moved_entry_list *add_lines_to_move_detection(struct diff_options *o, |
| 1057 | struct mem_pool *entry_mem_pool) |
| 1058 | { |
| 1059 | struct moved_entry *prev_line = NULL; |
| 1060 | struct mem_pool interned_pool; |
| 1061 | struct hashmap interned_map; |
| 1062 | struct moved_entry_list *entry_list = NULL; |
| 1063 | size_t entry_list_alloc = 0; |
| 1064 | unsigned id = 0; |
| 1065 | int n; |
| 1066 | |
| 1067 | hashmap_init(&interned_map, interned_diff_symbol_cmp, o, 8096); |
| 1068 | mem_pool_init(&interned_pool, 1024 * 1024); |
| 1069 | |
| 1070 | for (n = 0; n < o->emitted_symbols->nr; n++) { |
| 1071 | struct interned_diff_symbol key; |
| 1072 | struct emitted_diff_symbol *l = &o->emitted_symbols->buf[n]; |
| 1073 | struct interned_diff_symbol *s; |
| 1074 | struct moved_entry *entry; |
| 1075 | |
| 1076 | if (l->s != DIFF_SYMBOL_PLUS && l->s != DIFF_SYMBOL_MINUS) { |
| 1077 | prev_line = NULL; |
| 1078 | continue; |
| 1079 | } |
| 1080 | |
| 1081 | if (o->color_moved_ws_handling & |
| 1082 | COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE) |
| 1083 | fill_es_indent_data(l); |
| 1084 | |
| 1085 | prepare_entry(o, l, &key); |
| 1086 | s = hashmap_get_entry(&interned_map, &key, ent, &key.ent); |
| 1087 | if (s) { |
| 1088 | l->id = s->es->id; |
| 1089 | } else { |
| 1090 | l->id = id; |
| 1091 | ALLOC_GROW_BY(entry_list, id, 1, entry_list_alloc); |
| 1092 | hashmap_add(&interned_map, |
| 1093 | memcpy(mem_pool_alloc(&interned_pool, |
| 1094 | sizeof(key)), |
| 1095 | &key, sizeof(key))); |
| 1096 | } |
| 1097 | entry = mem_pool_alloc(entry_mem_pool, sizeof(*entry)); |
| 1098 | entry->es = l; |
| 1099 | entry->next_line = NULL; |
| 1100 | if (prev_line && prev_line->es->s == l->s) |
| 1101 | prev_line->next_line = entry; |
| 1102 | prev_line = entry; |
| 1103 | if (l->s == DIFF_SYMBOL_PLUS) { |
| 1104 | entry->next_match = entry_list[l->id].add; |
| 1105 | entry_list[l->id].add = entry; |
| 1106 | } else { |
| 1107 | entry->next_match = entry_list[l->id].del; |
| 1108 | entry_list[l->id].del = entry; |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | hashmap_clear(&interned_map); |
| 1113 | mem_pool_discard(&interned_pool, 0); |
no test coverage detected