diff -r bdec069d2239 -r 73b3485e96f1 src/server/ucx/map.h --- a/src/server/ucx/map.h Thu Jul 11 14:21:23 2013 +0200 +++ b/src/server/ucx/map.h Tue Jul 16 12:14:13 2013 +0200 @@ -38,8 +38,8 @@ extern "C" { #endif -#define UCX_MAP_FOREACH(elm,iter) \ - for(;ucx_map_iter_next(&iter,(void**)&elm)==0;) +#define UCX_MAP_FOREACH(key,elm,iter) \ + for(UcxKey key;ucx_map_iter_next(&iter,&key, (void**)&elm)==0;) typedef struct UcxMap UcxMap; typedef struct UcxKey UcxKey; @@ -55,6 +55,7 @@ typedef void*(*ucx_map_coder)(void*,void*,size_t*); struct UcxMap { + UcxAllocator *allocator; UcxMapElement **map; size_t size; size_t count; @@ -80,6 +81,7 @@ UcxMap *ucx_map_new(size_t size); +UcxMap *ucx_map_new_allocator(size_t size, UcxAllocator *allocator); void ucx_map_free(UcxMap *map); /* you cannot clone maps with more than 390 mio entries */ int ucx_map_copy(UcxMap *restrict from, UcxMap *restrict to, @@ -92,11 +94,11 @@ void* ucx_map_remove(UcxMap *map, UcxKey key); #define ucx_map_sstr_put(m, s, d) \ - ucx_map_put(m, ucx_key(s.ptr, s.length), d) + ucx_map_put(m, ucx_key(s.ptr, s.length), (void*)d) #define ucx_map_cstr_put(m, s, d) \ - ucx_map_put(m, ucx_key((void*)s, strlen(s)), d) + ucx_map_put(m, ucx_key((void*)s, strlen(s)), (void*)d) #define ucx_map_int_put(m, i, d) \ - ucx_map_put(m, ucx_key((void*)&i, sizeof(i)), d) + ucx_map_put(m, ucx_key((void*)&i, sizeof(i)), (void*)d) #define ucx_map_sstr_get(m, s) \ ucx_map_get(m, ucx_key(s.ptr, s.length)) @@ -118,17 +120,8 @@ UcxMapIterator ucx_map_iterator(UcxMap *map); -int ucx_map_iter_next(UcxMapIterator *i, void **elm); - -/* use macros for string maps only, values are not encoded */ -#define ucx_map_load(map, f, alloc) ucx_map_load_enc(map, f, alloc, NULL, NULL) -#define ucx_map_store(map, f) ucx_map_store_enc(map, f, NULL, NULL) +int ucx_map_iter_next(UcxMapIterator *i, UcxKey *key, void **elm); -int ucx_map_load_enc(UcxMap *map, FILE *f, UcxAllocator allocator, - ucx_map_coder decoder, void* decdata); -/* encoders shall provide null terminated strings*/ -int ucx_map_store_enc(UcxMap *map, FILE *f, - ucx_map_coder encoder, void* encdata); #ifdef __cplusplus }