File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -90,14 +90,7 @@ struct btf_dump {
9090
9191static size_t str_hash_fn (const void * key , void * ctx )
9292{
93- const char * s = key ;
94- size_t h = 0 ;
95-
96- while (* s ) {
97- h = h * 31 + * s ;
98- s ++ ;
99- }
100- return h ;
93+ return str_hash (key );
10194}
10295
10396static bool str_equal_fn (const void * a , const void * b , void * ctx )
Original file line number Diff line number Diff line change @@ -25,6 +25,18 @@ static inline size_t hash_bits(size_t h, int bits)
2525#endif
2626}
2727
28+ /* generic C-string hashing function */
29+ static inline size_t str_hash (const char * s )
30+ {
31+ size_t h = 0 ;
32+
33+ while (* s ) {
34+ h = h * 31 + * s ;
35+ s ++ ;
36+ }
37+ return h ;
38+ }
39+
2840typedef size_t (* hashmap_hash_fn )(const void * key , void * ctx );
2941typedef bool (* hashmap_equal_fn )(const void * key1 , const void * key2 , void * ctx );
3042
You can’t perform that action at this time.
0 commit comments