72 alfree(map->allocator, elem); |
72 alfree(map->allocator, elem); |
73 elem = next; |
73 elem = next; |
74 } while (elem != NULL); |
74 } while (elem != NULL); |
75 } |
75 } |
76 } |
76 } |
|
77 } |
|
78 |
|
79 void ucx_map_free(UcxMap *map) { |
|
80 ucx_map_free_elmlist_contents(map); |
77 alfree(map->allocator, map->map); |
81 alfree(map->allocator, map->map); |
78 } |
|
79 |
|
80 void ucx_map_free(UcxMap *map) { |
|
81 ucx_map_free_elmlist(map); |
|
82 alfree(map->allocator, map); |
82 alfree(map->allocator, map); |
|
83 } |
|
84 |
|
85 void ucx_map_clear(UcxMap *map) { |
|
86 ucx_map_free_elmlist_contents(map); |
|
87 memset(map->map, 0, map->size*sizeof(UcxMapElement*)); |
|
88 map->count = 0; |
83 } |
89 } |
84 |
90 |
85 int ucx_map_copy(UcxMap *restrict from, UcxMap *restrict to, |
91 int ucx_map_copy(UcxMap *restrict from, UcxMap *restrict to, |
86 copy_func fnc, void *data) { |
92 copy_func fnc, void *data) { |
87 UcxMapIterator i = ucx_map_iterator(from); |
93 UcxMapIterator i = ucx_map_iterator(from); |
122 } |
128 } |
123 map->count = 0; |
129 map->count = 0; |
124 ucx_map_copy(&oldmap, map, NULL, NULL); |
130 ucx_map_copy(&oldmap, map, NULL, NULL); |
125 |
131 |
126 /* free the UcxMapElement list of oldmap */ |
132 /* free the UcxMapElement list of oldmap */ |
127 ucx_map_free_elmlist(&oldmap); |
133 ucx_map_free_elmlist_contents(&oldmap); |
|
134 alfree(map->allocator, oldmap.map); |
128 } |
135 } |
129 return 0; |
136 return 0; |
130 } |
137 } |
131 |
138 |
132 int ucx_map_put(UcxMap *map, UcxKey key, void *data) { |
139 int ucx_map_put(UcxMap *map, UcxKey key, void *data) { |