40 } |
37 } |
41 free(map->map); |
38 free(map->map); |
42 free(map); |
39 free(map); |
43 } |
40 } |
44 |
41 |
|
42 UcxMap *ucx_map_clone(UcxMap *map, copy_func fnc, void *data) { |
|
43 UcxMap *newmap = ucx_map_new(map->size); |
|
44 UcxMapIterator i = ucx_map_iterator(map); |
|
45 void *value; |
|
46 UCX_MAP_FOREACH(value, i) { |
|
47 ucx_map_put(newmap, i.cur->key, fnc ? fnc(value, data) : value); |
|
48 } |
|
49 return newmap; |
|
50 } |
|
51 |
45 int ucx_map_put(UcxMap *map, UcxKey key, void *data) { |
52 int ucx_map_put(UcxMap *map, UcxKey key, void *data) { |
46 if(key.hash == 0) { |
53 if(key.hash == 0) { |
47 key.hash = ucx_hash((char*)key.data, key.len); |
54 key.hash = ucx_hash((char*)key.data, key.len); |
48 } |
55 } |
49 |
56 |