Wed, 06 Feb 2013 12:55:56 +0100
some fixes
ucx/buffer.c | file | annotate | diff | comparison | revisions | |
ucx/map.h | file | annotate | diff | comparison | revisions |
1.1 --- a/ucx/buffer.c Thu Jan 17 23:56:48 2013 +0100 1.2 +++ b/ucx/buffer.c Wed Feb 06 12:55:56 2013 +0100 1.3 @@ -8,7 +8,7 @@ 1.4 if (buffer) { 1.5 buffer->flags = flags; 1.6 if (!space) { 1.7 - buffer->space = malloc(size); 1.8 + buffer->space = (char*)malloc(size); 1.9 if (!buffer->space) { 1.10 free(buffer); 1.11 return NULL; 1.12 @@ -16,7 +16,7 @@ 1.13 memset(buffer->space, 0, size); 1.14 buffer->flags |= UCX_BUFFER_AUTOFREE; 1.15 } else { 1.16 - buffer->space = space; 1.17 + buffer->space = (char*)space; 1.18 } 1.19 buffer->capacity = size; 1.20 buffer->size = 0; 1.21 @@ -48,7 +48,7 @@ 1.22 1.23 UcxBuffer *dst = (UcxBuffer*) malloc(sizeof(UcxBuffer)); 1.24 if (dst) { 1.25 - dst->space = malloc(length); 1.26 + dst->space = (char*)malloc(length); 1.27 if (!dst->space) { 1.28 free(dst); 1.29 return NULL; 1.30 @@ -95,7 +95,7 @@ 1.31 size_t newcap = buffer->capacity; 1.32 while (buffer->pos + len > newcap) newcap <<= 1; 1.33 1.34 - char *newspace = realloc(buffer->space, newcap); 1.35 + char *newspace = (char*)realloc(buffer->space, newcap); 1.36 if (newspace) { 1.37 memset(newspace+buffer->size, 0, newcap-buffer->size); 1.38 buffer->space = newspace; 1.39 @@ -185,7 +185,7 @@ 1.40 size_t ucx_buffer_generic_copy(void *s1, void *s2, 1.41 read_func readfnc, write_func writefnc, size_t bufsize) { 1.42 size_t ncp = 0; 1.43 - char *buf = malloc(bufsize); 1.44 + char *buf = (char*)malloc(bufsize); 1.45 if(buf == NULL) { 1.46 return 0; 1.47 }
2.1 --- a/ucx/map.h Thu Jan 17 23:56:48 2013 +0100 2.2 +++ b/ucx/map.h Wed Feb 06 12:55:56 2013 +0100 2.3 @@ -68,17 +68,25 @@ 2.4 void* ucx_map_remove(UcxMap *map, UcxKey key); 2.5 2.6 #define ucx_map_sstr_put(m, s, d) \ 2.7 - ucx_map_put(m, ucx_key((void*)s.ptr, s.length), d) 2.8 + ucx_map_put(m, ucx_key(s.ptr, s.length), d) 2.9 #define ucx_map_cstr_put(m, s, d) \ 2.10 - ucx_map_put(m, ucx_key((void*)s, 1+strlen(s)), d) 2.11 + ucx_map_put(m, ucx_key((void*)s, strlen(s)), d) 2.12 +#define ucx_map_int_put(m, i, d) \ 2.13 + ucx_map_put(m, ucx_key((void*)&i, sizeof(d)), d) 2.14 + 2.15 #define ucx_map_sstr_get(m, s) \ 2.16 - ucx_map_get(m, ucx_key((void*)s.ptr, s.length)) 2.17 + ucx_map_get(m, ucx_key(s.ptr, s.length)) 2.18 #define ucx_map_cstr_get(m, s) \ 2.19 - ucx_map_get(m, ucx_key((void*)s, 1+strlen(s))) 2.20 + ucx_map_get(m, ucx_key((void*)s, strlen(s))) 2.21 +#define ucx_map_int_get(m, i) \ 2.22 + ucx_map_get(m, ucx_key((void*)&i, sizeof(int))) 2.23 + 2.24 #define ucx_map_sstr_remove(m, s) \ 2.25 - ucx_map_remove(m, ucx_key((void*)s.ptr, s.length)) 2.26 + ucx_map_remove(m, ucx_key(s.ptr, s.length)) 2.27 #define ucx_map_cstr_remove(m, s) \ 2.28 - ucx_map_remove(m, ucx_key((void*)s, 1+strlen(s))) 2.29 + ucx_map_remove(m, ucx_key((void*)s, strlen(s))) 2.30 +#define ucx_map_int_remove(m, i) \ 2.31 + ucx_map_remove(m, ucx_key((void*)&i, sizeof(int))) 2.32 2.33 UcxKey ucx_key(void *data, size_t len); 2.34