30 #include <string.h> |
30 #include <string.h> |
31 |
31 |
32 #include "map.h" |
32 #include "map.h" |
33 |
33 |
34 UcxMap *ucx_map_new(size_t size) { |
34 UcxMap *ucx_map_new(size_t size) { |
35 return ucx_map_new_a(size, NULL); |
35 return ucx_map_new_a(NULL, size); |
36 } |
36 } |
37 |
37 |
38 UcxMap *ucx_map_new_a(size_t size, UcxAllocator *allocator) { |
38 UcxMap *ucx_map_new_a(UcxAllocator *allocator, size_t size) { |
39 if(size == 0) { |
39 if(size == 0) { |
40 size = 16; |
40 size = 16; |
41 } |
41 } |
42 |
42 |
43 if(!allocator) { |
43 if(!allocator) { |
44 allocator = ucx_default_allocator(); |
44 allocator = ucx_default_allocator(); |
45 } |
45 } |
46 |
46 |
47 UcxMap *map = (UcxMap*)allocator->malloc(allocator->pool, sizeof(UcxMap)); |
47 UcxMap *map = (UcxMap*)allocator->malloc(allocator->pool, sizeof(UcxMap)); |
48 if(map == NULL) { |
48 if (!map) { |
49 return NULL; |
49 return NULL; |
50 } |
50 } |
51 |
51 |
52 map->allocator = allocator; |
52 map->allocator = allocator; |
53 map->map = (UcxMapElement**)allocator->calloc( |
53 map->map = (UcxMapElement**)allocator->calloc( |