1.1 --- a/ucx/map.h Fri Oct 05 10:25:33 2012 +0200 1.2 +++ b/ucx/map.h Fri Oct 05 11:52:53 2012 +0200 1.3 @@ -7,6 +7,7 @@ 1.4 1.5 #include "ucx.h" 1.6 #include "string.h" 1.7 +#include "mempool.h" 1.8 #include <stdio.h> 1.9 1.10 #ifdef __cplusplus 1.11 @@ -21,6 +22,14 @@ 1.12 typedef struct UcxMapElement UcxMapElement; 1.13 typedef struct UcxMapIterator UcxMapIterator; 1.14 1.15 +/* 1.16 + * param 1: element 1.17 + * param 2: additional data 1.18 + * param 3: size of encoded data will be stored here 1.19 + * returns encoded / decoded string or NULL on failure 1.20 + */ 1.21 +typedef void*(*ucx_map_coder)(void*,void*,size_t*); 1.22 + 1.23 struct UcxMap { 1.24 UcxMapElement **map; 1.25 size_t size; 1.26 @@ -67,12 +76,14 @@ 1.27 int ucx_map_iter_next(UcxMapIterator *i, void **elm); 1.28 1.29 /* use macros for string maps only, values are not encoded */ 1.30 -#define ucx_map_load(map, f) ucx_map_load_enc(map, f, NULL, NULL) 1.31 +#define ucx_map_load(map, f, alloc) ucx_map_load_enc(map, f, alloc, NULL, NULL) 1.32 #define ucx_map_store(map, f) ucx_map_store_enc(map, f, NULL, NULL) 1.33 1.34 -int ucx_map_load_enc(UcxMap *map, FILE *f, copy_func decoder, void* decdata); 1.35 +int ucx_map_load_enc(UcxMap *map, FILE *f, UcxAllocator allocator, 1.36 + ucx_map_coder decoder, void* decdata); 1.37 /* encoders shall provide null terminated strings*/ 1.38 -int ucx_map_store_enc(UcxMap *map, FILE *f, copy_func encoder, void* encdata); 1.39 +int ucx_map_store_enc(UcxMap *map, FILE *f, 1.40 + ucx_map_coder encoder, void* encdata); 1.41 1.42 #ifdef __cplusplus 1.43 }