2
2
#include "prefix-map.h"
3
3
4
4
static int map_cmp (const void * unused_cmp_data ,
5
- const void * entry ,
6
- const void * entry_or_key ,
5
+ const struct hashmap_entry * entry ,
6
+ const struct hashmap_entry * entry_or_key ,
7
7
const void * unused_keydata )
8
8
{
9
- const struct prefix_map_entry * a = entry ;
10
- const struct prefix_map_entry * b = entry_or_key ;
9
+ const struct prefix_map_entry * a =
10
+ container_of (entry , const struct prefix_map_entry , e );
11
+ const struct prefix_map_entry * b =
12
+ container_of (entry_or_key , const struct prefix_map_entry , e );
11
13
12
14
return a -> prefix_length != b -> prefix_length ||
13
15
strncmp (a -> name , b -> name , a -> prefix_length );
@@ -20,8 +22,8 @@ static void add_prefix_entry(struct hashmap *map, const char *name,
20
22
result -> name = name ;
21
23
result -> prefix_length = prefix_length ;
22
24
result -> item = item ;
23
- hashmap_entry_init (result , memhash (name , prefix_length ));
24
- hashmap_add (map , result );
25
+ hashmap_entry_init (& result -> e , memhash (name , prefix_length ));
26
+ hashmap_add (map , & result -> e );
25
27
}
26
28
27
29
static void init_prefix_map (struct prefix_map * prefix_map ,
@@ -48,8 +50,8 @@ static void add_prefix_item(struct prefix_map *prefix_map,
48
50
break ;
49
51
50
52
e .prefix_length = j ;
51
- hashmap_entry_init (& e , memhash (e .name , j ));
52
- e2 = hashmap_get (& prefix_map -> map , & e , NULL );
53
+ hashmap_entry_init (& e . e , memhash (e .name , j ));
54
+ e2 = hashmap_get_entry (& prefix_map -> map , & e , e , NULL );
53
55
if (!e2 ) {
54
56
/* prefix is unique at this stage */
55
57
item -> prefix_length = j ;
@@ -105,5 +107,5 @@ void find_unique_prefixes(struct prefix_item **list, size_t nr,
105
107
init_prefix_map (& prefix_map , min_length , max_length );
106
108
for (i = 0 ; i < nr ; i ++ )
107
109
add_prefix_item (& prefix_map , list [i ]);
108
- hashmap_free (& prefix_map .map , 1 );
110
+ hashmap_free_entries (& prefix_map .map , struct prefix_map_entry , e );
109
111
}
0 commit comments