@@ -67,13 +67,13 @@ struct buddy *buddy_embed_alignment(unsigned char *main, size_t memory_size, siz
6767struct buddy * buddy_resize (struct buddy * buddy , size_t new_memory_size );
6868
6969/* Tests if the allocator can be shrunk in half */
70- unsigned int buddy_can_shrink (struct buddy * buddy );
70+ bool buddy_can_shrink (struct buddy * buddy );
7171
7272/* Tests if the allocator is completely empty */
73- unsigned int buddy_is_empty (struct buddy * buddy );
73+ bool buddy_is_empty (struct buddy * buddy );
7474
7575/* Tests if the allocator is completely full */
76- unsigned int buddy_is_full (struct buddy * buddy );
76+ bool buddy_is_full (struct buddy * buddy );
7777
7878/* Reports the arena size */
7979size_t buddy_arena_size (struct buddy * buddy );
@@ -234,7 +234,7 @@ static size_t buddy_tree_sizeof(uint8_t order);
234234static struct buddy_tree * buddy_tree_init (unsigned char * at , uint8_t order );
235235
236236/* Indicates whether this is a valid position for the tree */
237- static unsigned int buddy_tree_valid (struct buddy_tree * t , struct buddy_tree_pos pos );
237+ static bool buddy_tree_valid (struct buddy_tree * t , struct buddy_tree_pos pos );
238238
239239/* Returns the order of the specified buddy allocation tree */
240240static uint8_t buddy_tree_order (struct buddy_tree * t );
@@ -278,7 +278,7 @@ static size_t buddy_tree_index(struct buddy_tree_pos pos);
278278static struct buddy_tree_interval buddy_tree_interval (struct buddy_tree * t , struct buddy_tree_pos pos );
279279
280280/* Checks if one interval contains another */
281- static unsigned int buddy_tree_interval_contains (struct buddy_tree_interval outer ,
281+ static bool buddy_tree_interval_contains (struct buddy_tree_interval outer ,
282282 struct buddy_tree_interval inner );
283283
284284/* Return a walk state structure starting from the root of a tree */
@@ -305,10 +305,10 @@ static void buddy_tree_release(struct buddy_tree *t, struct buddy_tree_pos pos);
305305static struct buddy_tree_pos buddy_tree_find_free (struct buddy_tree * t , uint8_t depth );
306306
307307/* Tests if the indicated position is available for allocation */
308- static unsigned int buddy_tree_is_free (struct buddy_tree * t , struct buddy_tree_pos pos );
308+ static bool buddy_tree_is_free (struct buddy_tree * t , struct buddy_tree_pos pos );
309309
310310/* Tests if the tree can be shrank in half */
311- static unsigned int buddy_tree_can_shrink (struct buddy_tree * t );
311+ static bool buddy_tree_can_shrink (struct buddy_tree * t );
312312
313313/*
314314 * Debug functions
@@ -339,7 +339,7 @@ static inline void bitset_set(unsigned char *bitset, size_t pos);
339339
340340static inline void bitset_clear (unsigned char * bitset , size_t pos );
341341
342- static inline unsigned char bitset_test (const unsigned char * bitset , size_t pos );
342+ static inline bool bitset_test (const unsigned char * bitset , size_t pos );
343343
344344static void bitset_shift_left (unsigned char * bitset , size_t from_pos , size_t to_pos , size_t by );
345345
@@ -416,7 +416,7 @@ static void buddy_toggle_virtual_slots(struct buddy *buddy, unsigned int state);
416416static void buddy_toggle_range_reservation (struct buddy * buddy , void * ptr , size_t requested_size , unsigned int state );
417417static struct buddy * buddy_resize_standard (struct buddy * buddy , size_t new_memory_size );
418418static struct buddy * buddy_resize_embedded (struct buddy * buddy , size_t new_memory_size );
419- static unsigned int buddy_is_free (struct buddy * buddy , size_t from );
419+ static bool buddy_is_free (struct buddy * buddy , size_t from );
420420static struct buddy_embed_check buddy_embed_offset (size_t memory_size , size_t alignment );
421421static struct buddy_tree_pos deepest_position_for_offset (struct buddy * buddy , size_t offset );
422422
@@ -587,26 +587,26 @@ static struct buddy *buddy_resize_embedded(struct buddy *buddy, size_t new_memor
587587 return relocated ;
588588}
589589
590- unsigned int buddy_can_shrink (struct buddy * buddy ) {
590+ bool buddy_can_shrink (struct buddy * buddy ) {
591591 if (buddy == NULL ) {
592- return 0 ;
592+ return false ;
593593 }
594594 return buddy_is_free (buddy , buddy -> memory_size / 2 );
595595}
596596
597- unsigned int buddy_is_empty (struct buddy * buddy ) {
597+ bool buddy_is_empty (struct buddy * buddy ) {
598598 if (buddy == NULL ) {
599- return 1 ;
599+ return false ;
600600 }
601601 return buddy_is_free (buddy , 0 );
602602}
603603
604- unsigned int buddy_is_full (struct buddy * buddy ) {
604+ bool buddy_is_full (struct buddy * buddy ) {
605605 struct buddy_tree * tree ;
606606 struct buddy_tree_pos pos ;
607607
608608 if (buddy == NULL ) {
609- return 0 ;
609+ return false ;
610610 }
611611 tree = buddy_tree (buddy );
612612 pos = buddy_tree_root ();
@@ -1114,7 +1114,7 @@ static void buddy_toggle_range_reservation(struct buddy *buddy, void *ptr, size_
11141114 after the indicated relative memory index. Used to check if
11151115 the arena can be downsized.
11161116 The from argument is already adjusted for alignment by caller */
1117- static unsigned int buddy_is_free (struct buddy * buddy , size_t from ) {
1117+ static bool buddy_is_free (struct buddy * buddy , size_t from ) {
11181118 struct buddy_tree * tree ;
11191119 struct buddy_tree_interval query_range ;
11201120 struct buddy_tree_pos pos ;
@@ -1142,12 +1142,12 @@ static unsigned int buddy_is_free(struct buddy *buddy, size_t from) {
11421142 }
11431143 /* pos is now tracking an overlapping segment */
11441144 if (! buddy_tree_is_free (tree , pos )) {
1145- return 0 ;
1145+ return false ;
11461146 }
11471147 /* Advance check */
11481148 pos = buddy_tree_right_adjacent (current_test_range .to );
11491149 }
1150- return 1 ;
1150+ return true ;
11511151}
11521152
11531153static struct buddy_embed_check buddy_embed_offset (size_t memory_size , size_t alignment ) {
@@ -1380,7 +1380,7 @@ static void buddy_tree_shrink(struct buddy_tree *t, uint8_t desired_order) {
13801380 }
13811381}
13821382
1383- static unsigned int buddy_tree_valid (struct buddy_tree * t , struct buddy_tree_pos pos ) {
1383+ static bool buddy_tree_valid (struct buddy_tree * t , struct buddy_tree_pos pos ) {
13841384 return pos .index && (pos .index < t -> upper_pos_bound );
13851385}
13861386
@@ -1508,7 +1508,7 @@ static struct buddy_tree_interval buddy_tree_interval(struct buddy_tree *t, stru
15081508 return result ;
15091509}
15101510
1511- static unsigned int buddy_tree_interval_contains (struct buddy_tree_interval outer ,
1511+ static bool buddy_tree_interval_contains (struct buddy_tree_interval outer ,
15121512 struct buddy_tree_interval inner ) {
15131513 return (inner .from .index >= outer .from .index )
15141514 && (inner .from .index <= outer .to .index )
@@ -1650,9 +1650,9 @@ static struct buddy_tree_pos buddy_tree_find_free(struct buddy_tree *t, uint8_t
16501650 return current_pos ;
16511651}
16521652
1653- static unsigned int buddy_tree_is_free (struct buddy_tree * t , struct buddy_tree_pos pos ) {
1653+ static bool buddy_tree_is_free (struct buddy_tree * t , struct buddy_tree_pos pos ) {
16541654 if (buddy_tree_status (t , pos )) {
1655- return 0 ;
1655+ return false ;
16561656 }
16571657 pos = buddy_tree_parent (pos );
16581658 while (buddy_tree_valid (t , pos )) {
@@ -1663,22 +1663,22 @@ static unsigned int buddy_tree_is_free(struct buddy_tree *t, struct buddy_tree_p
16631663 }
16641664 pos = buddy_tree_parent (pos );
16651665 }
1666- return 1 ;
1666+ return true ;
16671667}
16681668
1669- static unsigned int buddy_tree_can_shrink (struct buddy_tree * t ) {
1669+ static bool buddy_tree_can_shrink (struct buddy_tree * t ) {
16701670 struct internal_position root_internal ;
16711671 size_t root_value ;
16721672
16731673 if (buddy_tree_status (t , buddy_tree_right_child (buddy_tree_root ())) != 0 ) {
1674- return 0 ; /* Refusing to shrink with right subtree still used! */
1674+ return false ; /* Refusing to shrink with right subtree still used! */
16751675 }
16761676 root_internal = buddy_tree_internal_position_tree (t , buddy_tree_root ());
16771677 root_value = read_from_internal_position (buddy_tree_bits (t ), root_internal );
16781678 if (root_value == root_internal .local_offset ) {
1679- return 0 ; /* Refusing to shrink with the root fully-allocated! */
1679+ return false ; /* Refusing to shrink with the root fully-allocated! */
16801680 }
1681- return 1 ;
1681+ return true ;
16821682}
16831683
16841684static void buddy_tree_debug (struct buddy_tree * t , struct buddy_tree_pos pos ,
@@ -1805,7 +1805,7 @@ static inline void bitset_clear(unsigned char *bitset, size_t pos) {
18051805 bitset [bucket ] &= ~bitset_index_mask [index ];
18061806}
18071807
1808- static inline unsigned char bitset_test (const unsigned char * bitset , size_t pos ) {
1808+ static inline bool bitset_test (const unsigned char * bitset , size_t pos ) {
18091809 size_t bucket = pos / CHAR_BIT ;
18101810 size_t index = pos % CHAR_BIT ;
18111811 return bitset [bucket ] & bitset_index_mask [index ];
0 commit comments