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);
120 range_list_t *ranges,
127 if (ranges->num_ranges == ranges->array_length) {
128 ranges->array_length += PARALLEL_ARRAY_SIZE;
129 ranges->array = REALLOC(ranges->array,
130 ranges->array_length*sizeof(range_t));
132 ranges->array[ranges->num_ranges].start = start;
133 ranges->array[ranges->num_ranges].length = length;
134 ranges->array[ranges->num_ranges].user = user;
135 ranges->array[ranges->num_ranges].err_fn = err_fn;
136 ranges->array[ranges->num_ranges].user_dtor = user_dtor;
137 ranges->num_ranges++;
140 range_list_t *sort_ranges(range_list_t *ranges) {
141 if (ranges->num_ranges > 1)
142 qsort(ranges->array, ranges->num_ranges, sizeof(range_t), range_cmp);
143 ranges->is_sorted = 1;
144 return ranges;
147 range_t *find_range(range_list_t *ranges, GElf_Off value) {
150 for (i = 0; i < ranges->num_ranges; i++) {
151 if (ranges->array[i].start <= value &&
152 value < ranges->array[i].start + ranges->array[i].length)
153 return ranges->array + i;
157 ASSERT(ranges->is_sorted); /* The range list must be sorted */
163 ranges->array, ranges->num_ranges, sizeof(range_t),
168 int get_num_ranges(const range_list_t *ranges)
170 return ranges->num_ranges;
173 range_t *get_sorted_ranges(const range_list_t *ranges, int *num_ranges) {
174 ASSERT(ranges->is_sorted); /* The range list must be sorted */
176 *num_ranges = ranges->num_ranges;
178 return ranges->array;
181 GElf_Off get_last_address(const range_list_t *ranges) {
182 ASSERT(ranges->num_ranges);
184 ranges->array[ranges->num_ranges-1].start +
185 ranges->array[ranges->num_ranges-1].length;
212 FREE(info->ranges);
227 PRINT("Contiguous-range overlap error. Printing contained ranges:\n");
229 PRINT("\tLeft ranges:\n");
232 left_data->ranges[cnt].start,
233 left_data->ranges[cnt].start + left_data->ranges[cnt].length);
235 PRINT("\tRight ranges:\n");
238 right_data->ranges[cnt].start,
239 right_data->ranges[cnt].start + right_data->ranges[cnt].length);
253 range_t *ranges = get_sorted_ranges(input, &num_ranges);
259 int total_length = ranges[start_idx].length;
261 if (ranges[old_end_idx].start + ranges[old_end_idx].length !=
262 ranges[end_idx].start)
265 total_length += ranges[old_end_idx].length;
271 user->ranges = (range_t *)MALLOC(user->num_ranges * sizeof(range_t));
274 user->ranges[i] = ranges[start_idx + i];
276 ranges[start_idx].start,