regfi
 All Data Structures Files Functions Variables Groups Pages
range_list.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2010 Timothy D. Morgan
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3 of the License.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  * $Id: range_list.h 253 2011-06-13 02:27:42Z tim $
18  */
19 
30 #ifndef _RANGE_LIST_H
31 #define _RANGE_LIST_H
32 
33 #include <stdlib.h>
34 #include <stdbool.h>
35 #include <stdint.h>
36 #include <string.h>
37 #include <math.h>
38 #include <talloc.h>
39 
40 #include "compat.h"
41 
42 typedef struct _range_list_element
43 {
44  uint32_t offset;
45  uint32_t length;
46  void* data;
48 
49 
51 typedef struct _range_list
52 {
53  range_list_element** elements;
54  uint32_t elem_alloced;
55  uint32_t size;
56 } range_list;
57 
58 
63 _EXPORT()
65 
66 
74 _EXPORT()
75 void range_list_free(range_list* rl);
76 
77 
84 _EXPORT()
85 uint32_t range_list_size(const range_list* rl);
86 
87 
104 _EXPORT()
105 bool range_list_add(range_list* rl, uint32_t offset, uint32_t length, void* data);
106 
107 
117 _EXPORT()
118 bool range_list_remove(range_list* rl, uint32_t index);
119 
120 
129 _EXPORT()
130 const range_list_element* range_list_get(const range_list* rl, uint32_t index);
131 
132 
140 _EXPORT()
141 int32_t range_list_find(const range_list* rl, uint32_t offset);
142 
143 
155 _EXPORT()
156 void* range_list_find_data(const range_list* rl, uint32_t offset);
157 
158 
177 _EXPORT()
178 bool range_list_split_element(range_list* rl, uint32_t index, uint32_t offset);
179 
180 
190 _EXPORT()
191 bool range_list_has_range(range_list* rl, uint32_t start, uint32_t length);
192 
193 #endif