@@ -202,7 +202,7 @@ static sparsebit_num_t node_num_set(struct node *nodep)
202
202
/* Returns a pointer to the node that describes the
203
203
* lowest bit index.
204
204
*/
205
- static struct node * node_first (struct sparsebit * s )
205
+ static struct node * node_first (const struct sparsebit * s )
206
206
{
207
207
struct node * nodep ;
208
208
@@ -216,7 +216,7 @@ static struct node *node_first(struct sparsebit *s)
216
216
* lowest bit index > the index of the node pointed to by np.
217
217
* Returns NULL if no node with a higher index exists.
218
218
*/
219
- static struct node * node_next (struct sparsebit * s , struct node * np )
219
+ static struct node * node_next (const struct sparsebit * s , struct node * np )
220
220
{
221
221
struct node * nodep = np ;
222
222
@@ -244,7 +244,7 @@ static struct node *node_next(struct sparsebit *s, struct node *np)
244
244
* highest index < the index of the node pointed to by np.
245
245
* Returns NULL if no node with a lower index exists.
246
246
*/
247
- static struct node * node_prev (struct sparsebit * s , struct node * np )
247
+ static struct node * node_prev (const struct sparsebit * s , struct node * np )
248
248
{
249
249
struct node * nodep = np ;
250
250
@@ -273,7 +273,7 @@ static struct node *node_prev(struct sparsebit *s, struct node *np)
273
273
* subtree and duplicates the bit settings to the newly allocated nodes.
274
274
* Returns the newly allocated copy of subtree.
275
275
*/
276
- static struct node * node_copy_subtree (struct node * subtree )
276
+ static struct node * node_copy_subtree (const struct node * subtree )
277
277
{
278
278
struct node * root ;
279
279
@@ -307,7 +307,7 @@ static struct node *node_copy_subtree(struct node *subtree)
307
307
* index is within the bits described by the mask bits or the number of
308
308
* contiguous bits set after the mask. Returns NULL if there is no such node.
309
309
*/
310
- static struct node * node_find (struct sparsebit * s , sparsebit_idx_t idx )
310
+ static struct node * node_find (const struct sparsebit * s , sparsebit_idx_t idx )
311
311
{
312
312
struct node * nodep ;
313
313
@@ -393,7 +393,7 @@ static struct node *node_add(struct sparsebit *s, sparsebit_idx_t idx)
393
393
}
394
394
395
395
/* Returns whether all the bits in the sparsebit array are set. */
396
- bool sparsebit_all_set (struct sparsebit * s )
396
+ bool sparsebit_all_set (const struct sparsebit * s )
397
397
{
398
398
/*
399
399
* If any nodes there must be at least one bit set. Only case
@@ -775,7 +775,7 @@ static void node_reduce(struct sparsebit *s, struct node *nodep)
775
775
/* Returns whether the bit at the index given by idx, within the
776
776
* sparsebit array is set or not.
777
777
*/
778
- bool sparsebit_is_set (struct sparsebit * s , sparsebit_idx_t idx )
778
+ bool sparsebit_is_set (const struct sparsebit * s , sparsebit_idx_t idx )
779
779
{
780
780
struct node * nodep ;
781
781
@@ -921,7 +921,7 @@ static inline sparsebit_idx_t node_first_clear(struct node *nodep, int start)
921
921
* used by test cases after they detect an unexpected condition, as a means
922
922
* to capture diagnostic information.
923
923
*/
924
- static void sparsebit_dump_internal (FILE * stream , struct sparsebit * s ,
924
+ static void sparsebit_dump_internal (FILE * stream , const struct sparsebit * s ,
925
925
unsigned int indent )
926
926
{
927
927
/* Dump the contents of s */
@@ -969,7 +969,7 @@ void sparsebit_free(struct sparsebit **sbitp)
969
969
* sparsebit_alloc(). It can though already have bits set, which
970
970
* if different from src will be cleared.
971
971
*/
972
- void sparsebit_copy (struct sparsebit * d , struct sparsebit * s )
972
+ void sparsebit_copy (struct sparsebit * d , const struct sparsebit * s )
973
973
{
974
974
/* First clear any bits already set in the destination */
975
975
sparsebit_clear_all (d );
@@ -981,7 +981,7 @@ void sparsebit_copy(struct sparsebit *d, struct sparsebit *s)
981
981
}
982
982
983
983
/* Returns whether num consecutive bits starting at idx are all set. */
984
- bool sparsebit_is_set_num (struct sparsebit * s ,
984
+ bool sparsebit_is_set_num (const struct sparsebit * s ,
985
985
sparsebit_idx_t idx , sparsebit_num_t num )
986
986
{
987
987
sparsebit_idx_t next_cleared ;
@@ -1005,14 +1005,14 @@ bool sparsebit_is_set_num(struct sparsebit *s,
1005
1005
}
1006
1006
1007
1007
/* Returns whether the bit at the index given by idx. */
1008
- bool sparsebit_is_clear (struct sparsebit * s ,
1008
+ bool sparsebit_is_clear (const struct sparsebit * s ,
1009
1009
sparsebit_idx_t idx )
1010
1010
{
1011
1011
return !sparsebit_is_set (s , idx );
1012
1012
}
1013
1013
1014
1014
/* Returns whether num consecutive bits starting at idx are all cleared. */
1015
- bool sparsebit_is_clear_num (struct sparsebit * s ,
1015
+ bool sparsebit_is_clear_num (const struct sparsebit * s ,
1016
1016
sparsebit_idx_t idx , sparsebit_num_t num )
1017
1017
{
1018
1018
sparsebit_idx_t next_set ;
@@ -1041,13 +1041,13 @@ bool sparsebit_is_clear_num(struct sparsebit *s,
1041
1041
* value. Use sparsebit_any_set(), instead of sparsebit_num_set() > 0,
1042
1042
* to determine if the sparsebit array has any bits set.
1043
1043
*/
1044
- sparsebit_num_t sparsebit_num_set (struct sparsebit * s )
1044
+ sparsebit_num_t sparsebit_num_set (const struct sparsebit * s )
1045
1045
{
1046
1046
return s -> num_set ;
1047
1047
}
1048
1048
1049
1049
/* Returns whether any bit is set in the sparsebit array. */
1050
- bool sparsebit_any_set (struct sparsebit * s )
1050
+ bool sparsebit_any_set (const struct sparsebit * s )
1051
1051
{
1052
1052
/*
1053
1053
* Nodes only describe set bits. If any nodes then there
@@ -1070,20 +1070,20 @@ bool sparsebit_any_set(struct sparsebit *s)
1070
1070
}
1071
1071
1072
1072
/* Returns whether all the bits in the sparsebit array are cleared. */
1073
- bool sparsebit_all_clear (struct sparsebit * s )
1073
+ bool sparsebit_all_clear (const struct sparsebit * s )
1074
1074
{
1075
1075
return !sparsebit_any_set (s );
1076
1076
}
1077
1077
1078
1078
/* Returns whether all the bits in the sparsebit array are set. */
1079
- bool sparsebit_any_clear (struct sparsebit * s )
1079
+ bool sparsebit_any_clear (const struct sparsebit * s )
1080
1080
{
1081
1081
return !sparsebit_all_set (s );
1082
1082
}
1083
1083
1084
1084
/* Returns the index of the first set bit. Abort if no bits are set.
1085
1085
*/
1086
- sparsebit_idx_t sparsebit_first_set (struct sparsebit * s )
1086
+ sparsebit_idx_t sparsebit_first_set (const struct sparsebit * s )
1087
1087
{
1088
1088
struct node * nodep ;
1089
1089
@@ -1097,7 +1097,7 @@ sparsebit_idx_t sparsebit_first_set(struct sparsebit *s)
1097
1097
/* Returns the index of the first cleared bit. Abort if
1098
1098
* no bits are cleared.
1099
1099
*/
1100
- sparsebit_idx_t sparsebit_first_clear (struct sparsebit * s )
1100
+ sparsebit_idx_t sparsebit_first_clear (const struct sparsebit * s )
1101
1101
{
1102
1102
struct node * nodep1 , * nodep2 ;
1103
1103
@@ -1151,7 +1151,7 @@ sparsebit_idx_t sparsebit_first_clear(struct sparsebit *s)
1151
1151
/* Returns index of next bit set within s after the index given by prev.
1152
1152
* Returns 0 if there are no bits after prev that are set.
1153
1153
*/
1154
- sparsebit_idx_t sparsebit_next_set (struct sparsebit * s ,
1154
+ sparsebit_idx_t sparsebit_next_set (const struct sparsebit * s ,
1155
1155
sparsebit_idx_t prev )
1156
1156
{
1157
1157
sparsebit_idx_t lowest_possible = prev + 1 ;
@@ -1244,7 +1244,7 @@ sparsebit_idx_t sparsebit_next_set(struct sparsebit *s,
1244
1244
/* Returns index of next bit cleared within s after the index given by prev.
1245
1245
* Returns 0 if there are no bits after prev that are cleared.
1246
1246
*/
1247
- sparsebit_idx_t sparsebit_next_clear (struct sparsebit * s ,
1247
+ sparsebit_idx_t sparsebit_next_clear (const struct sparsebit * s ,
1248
1248
sparsebit_idx_t prev )
1249
1249
{
1250
1250
sparsebit_idx_t lowest_possible = prev + 1 ;
@@ -1300,7 +1300,7 @@ sparsebit_idx_t sparsebit_next_clear(struct sparsebit *s,
1300
1300
* and returns the index of the first sequence of num consecutively set
1301
1301
* bits. Returns a value of 0 of no such sequence exists.
1302
1302
*/
1303
- sparsebit_idx_t sparsebit_next_set_num (struct sparsebit * s ,
1303
+ sparsebit_idx_t sparsebit_next_set_num (const struct sparsebit * s ,
1304
1304
sparsebit_idx_t start , sparsebit_num_t num )
1305
1305
{
1306
1306
sparsebit_idx_t idx ;
@@ -1335,7 +1335,7 @@ sparsebit_idx_t sparsebit_next_set_num(struct sparsebit *s,
1335
1335
* and returns the index of the first sequence of num consecutively cleared
1336
1336
* bits. Returns a value of 0 of no such sequence exists.
1337
1337
*/
1338
- sparsebit_idx_t sparsebit_next_clear_num (struct sparsebit * s ,
1338
+ sparsebit_idx_t sparsebit_next_clear_num (const struct sparsebit * s ,
1339
1339
sparsebit_idx_t start , sparsebit_num_t num )
1340
1340
{
1341
1341
sparsebit_idx_t idx ;
@@ -1583,7 +1583,7 @@ static size_t display_range(FILE *stream, sparsebit_idx_t low,
1583
1583
* contiguous bits. This is done because '-' is used to specify command-line
1584
1584
* options, and sometimes ranges are specified as command-line arguments.
1585
1585
*/
1586
- void sparsebit_dump (FILE * stream , struct sparsebit * s ,
1586
+ void sparsebit_dump (FILE * stream , const struct sparsebit * s ,
1587
1587
unsigned int indent )
1588
1588
{
1589
1589
size_t current_line_len = 0 ;
@@ -1681,7 +1681,7 @@ void sparsebit_dump(FILE *stream, struct sparsebit *s,
1681
1681
* s. On error, diagnostic information is printed to stderr and
1682
1682
* abort is called.
1683
1683
*/
1684
- void sparsebit_validate_internal (struct sparsebit * s )
1684
+ void sparsebit_validate_internal (const struct sparsebit * s )
1685
1685
{
1686
1686
bool error_detected = false;
1687
1687
struct node * nodep , * prev = NULL ;
0 commit comments