Lines Matching refs:ranges
17 range_list_t *ranges = (range_list_t *)MALLOC(sizeof(range_list_t));
19 ranges->array = (range_t *)MALLOC(PARALLEL_ARRAY_SIZE*sizeof(range_t));
20 ranges->array_length = PARALLEL_ARRAY_SIZE;
21 ranges->num_ranges = 0;
23 ranges->is_sorted = 0;
25 return ranges;
28 void destroy_range_list(range_list_t *ranges) {
30 for (idx = 0; idx < ranges->num_ranges; idx++) {
31 if (ranges->array[idx].user_dtor) {
32 ASSERT(ranges->array[idx].user);
33 ranges->array[idx].user_dtor(ranges->array[idx].user);
36 FREE(ranges->array);
37 FREE(ranges);
102 range_list_t *ranges,
109 if (ranges->num_ranges == ranges->array_length) {
110 ranges->array_length += PARALLEL_ARRAY_SIZE;
111 ranges->array = REALLOC(ranges->array,
112 ranges->array_length*sizeof(range_t));
114 ranges->array[ranges->num_ranges].start = start;
115 ranges->array[ranges->num_ranges].length = length;
116 ranges->array[ranges->num_ranges].user = user;
117 ranges->array[ranges->num_ranges].err_fn = err_fn;
118 ranges->array[ranges->num_ranges].user_dtor = user_dtor;
119 ranges->num_ranges++;
122 range_list_t *sort_ranges(range_list_t *ranges) {
123 if (ranges->num_ranges > 1)
124 qsort(ranges->array, ranges->num_ranges, sizeof(range_t), range_cmp);
125 ranges->is_sorted = 1;
126 return ranges;
129 range_t *find_range(range_list_t *ranges, GElf_Off value) {
132 for (i = 0; i < ranges->num_ranges; i++) {
133 if (ranges->array[i].start <= value &&
134 value < ranges->array[i].start + ranges->array[i].length)
135 return ranges->array + i;
139 ASSERT(ranges->is_sorted); /* The range list must be sorted */
145 ranges->array, ranges->num_ranges, sizeof(range_t),
150 int get_num_ranges(const range_list_t *ranges)
152 return ranges->num_ranges;
155 range_t *get_sorted_ranges(const range_list_t *ranges, int *num_ranges) {
156 ASSERT(ranges->is_sorted); /* The range list must be sorted */
158 *num_ranges = ranges->num_ranges;
160 return ranges->array;
163 GElf_Off get_last_address(const range_list_t *ranges) {
164 ASSERT(ranges->num_ranges);
166 ranges->array[ranges->num_ranges-1].start +
167 ranges->array[ranges->num_ranges-1].length;
194 FREE(info->ranges);
209 PRINT("Contiguous-range overlap error. Printing contained ranges:\n");
211 PRINT("\tLeft ranges:\n");
214 left_data->ranges[cnt].start,
215 left_data->ranges[cnt].start + left_data->ranges[cnt].length);
217 PRINT("\tRight ranges:\n");
220 right_data->ranges[cnt].start,
221 right_data->ranges[cnt].start + right_data->ranges[cnt].length);
235 range_t *ranges = get_sorted_ranges(input, &num_ranges);
241 int total_length = ranges[start_idx].length;
243 if (ranges[old_end_idx].start + ranges[old_end_idx].length !=
244 ranges[end_idx].start)
247 total_length += ranges[old_end_idx].length;
253 user->ranges = (range_t *)MALLOC(user->num_ranges * sizeof(range_t));
256 user->ranges[i] = ranges[start_idx + i];
258 ranges[start_idx].start,