Replaced old utils with ucx

Sat, 14 Jan 2012 14:33:38 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 14 Jan 2012 14:33:38 +0100
changeset 15
cff9c4101dd7
parent 14
b8bf95b39952
child 16
a9bbd82d2dce

Replaced old utils with ucx

src/server/daemon/conf.c file | annotate | diff | comparison | revisions
src/server/daemon/conf.h file | annotate | diff | comparison | revisions
src/server/daemon/func.c file | annotate | diff | comparison | revisions
src/server/daemon/httplistener.c file | annotate | diff | comparison | revisions
src/server/daemon/httpparser.h file | annotate | diff | comparison | revisions
src/server/daemon/httprequest.h file | annotate | diff | comparison | revisions
src/server/daemon/vserver.h file | annotate | diff | comparison | revisions
src/server/safs/objecttype.c file | annotate | diff | comparison | revisions
src/server/ucx/dlist.c file | annotate | diff | comparison | revisions
src/server/ucx/dlist.h file | annotate | diff | comparison | revisions
src/server/ucx/list.c file | annotate | diff | comparison | revisions
src/server/ucx/list.h file | annotate | diff | comparison | revisions
src/server/ucx/map.c file | annotate | diff | comparison | revisions
src/server/ucx/map.h file | annotate | diff | comparison | revisions
src/server/ucx/mempool.c file | annotate | diff | comparison | revisions
src/server/ucx/mempool.h file | annotate | diff | comparison | revisions
src/server/ucx/objs.mk file | annotate | diff | comparison | revisions
src/server/ucx/sstring.c file | annotate | diff | comparison | revisions
src/server/ucx/sstring.h file | annotate | diff | comparison | revisions
src/server/ucx/string.c file | annotate | diff | comparison | revisions
src/server/ucx/string.h file | annotate | diff | comparison | revisions
src/server/ucx/ucx.h file | annotate | diff | comparison | revisions
src/server/util/list.c file | annotate | diff | comparison | revisions
src/server/util/list.h file | annotate | diff | comparison | revisions
src/server/util/map.c file | annotate | diff | comparison | revisions
src/server/util/map.h file | annotate | diff | comparison | revisions
src/server/util/objs.mk file | annotate | diff | comparison | revisions
src/server/util/strbuf.c file | annotate | diff | comparison | revisions
src/server/util/strbuf.h file | annotate | diff | comparison | revisions
src/server/webdav/saxhandler.cpp file | annotate | diff | comparison | revisions
src/server/webdav/webdav.c file | annotate | diff | comparison | revisions
src/server/webdav/webdav.h file | annotate | diff | comparison | revisions
--- a/src/server/daemon/conf.c	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/daemon/conf.c	Sat Jan 14 14:33:38 2012 +0100
@@ -37,7 +37,7 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 
-#include "../ucx/sstring.h"
+#include "../ucx/string.h"
 
 #include "httplistener.h"
 #include "conf.h"
--- a/src/server/daemon/conf.h	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/daemon/conf.h	Sat Jan 14 14:33:38 2012 +0100
@@ -31,7 +31,7 @@
 
 #include "../util/object.h"
 
-#include "../ucx/sstring.h"
+#include "../ucx/string.h"
 
 #ifdef	__cplusplus
 extern "C" {
--- a/src/server/daemon/func.c	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/daemon/func.c	Sat Jan 14 14:33:38 2012 +0100
@@ -30,13 +30,15 @@
 #include <stdlib.h>
 
 #include "../public/nsapi.h"
-#include "../util/map.h"
+
+#include "../ucx/map.h"
+
 #include "func.h"
 
-hashmap_t *function_map;
+UcxMap *function_map;
 
 void func_init() {
-    function_map = hashmap_new(128);
+    function_map = ucx_map_new(128);
 }
 
 void add_function(struct FuncStruct *func) {
@@ -44,7 +46,7 @@
 
     struct FuncStruct *f = malloc(sizeof(FuncStruct));
     *f = *func;
-    hashmap_put(function_map, sstr((char*)f->name), func);
+    ucx_map_cstr_put(function_map, (char*)f->name, func);
 }
 
 void add_functions(struct FuncStruct *funcs) {
@@ -56,5 +58,5 @@
 }
 
 FuncStruct* get_function(char *name) {
-    return hashmap_get(function_map, sstr(name));
+    return ucx_map_cstr_get(function_map, name);
 }
--- a/src/server/daemon/httplistener.c	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/daemon/httplistener.c	Sat Jan 14 14:33:38 2012 +0100
@@ -46,12 +46,12 @@
 #include <stdbool.h>
 #include <pthread.h>
 
-#include "../util/map.h"
+#include "../ucx/map.h"
 #include "httplistener.h"
 
 #include "session.h"
 
-hashmap_t *listener_map = NULL;
+UcxMap *listener_map = NULL;
 
 
 int start_all_listener() {
@@ -62,7 +62,7 @@
 }
 
 HttpListener* get_http_listener(char *name) {
-    return hashmap_get(listener_map, sstr(name));
+    return ucx_map_cstr_get(listener_map, name);
 }
 
 
@@ -105,9 +105,9 @@
     }
 
     if(listener_map == NULL) {
-        listener_map = hashmap_new(8);
+        listener_map = ucx_map_new(8);
     }
-    hashmap_put(listener_map, sstr(conf->name), listener);
+    ucx_map_cstr_put(listener_map, conf->name, listener);
     return listener;
 }
 
--- a/src/server/daemon/httpparser.h	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/daemon/httpparser.h	Sat Jan 14 14:33:38 2012 +0100
@@ -30,7 +30,7 @@
 #define	HTTPPARSER_H
 
 
-#include "../ucx/sstring.h"
+#include "../ucx/string.h"
 #include "httprequest.h"
 
 #ifdef	__cplusplus
--- a/src/server/daemon/httprequest.h	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/daemon/httprequest.h	Sat Jan 14 14:33:38 2012 +0100
@@ -29,7 +29,7 @@
 #ifndef HTTPREQUEST_H
 #define	HTTPREQUEST_H
 
-#include "../ucx/sstring.h"
+#include "../ucx/string.h"
 #include "sessionhandler.h"
 #include "../public/nsapi.h"
 #include "../util/pool.h"
--- a/src/server/daemon/vserver.h	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/daemon/vserver.h	Sat Jan 14 14:33:38 2012 +0100
@@ -32,7 +32,7 @@
 #include "../util/object.h"
 #include "../public/nsapi.h"
 
-#include "../ucx/sstring.h"
+#include "../ucx/string.h"
 
 #ifdef	__cplusplus
 extern "C" {
--- a/src/server/safs/objecttype.c	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/safs/objecttype.c	Sat Jan 14 14:33:38 2012 +0100
@@ -29,7 +29,7 @@
 #include "objecttype.h"
 #include "../util/pblock.h"
 
-#include "../ucx/sstring.h"
+#include "../ucx/string.h"
 
 int object_type_by_extension(pblock *pb, Session *sn, Request *rq) {
     sstr_t ppath = sstr(pblock_findkeyval(pb_key_ppath, rq->vars));
--- a/src/server/ucx/dlist.c	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/ucx/dlist.c	Sat Jan 14 14:33:38 2012 +0100
@@ -1,5 +1,34 @@
 #include "dlist.h"
 
+UcxDlist *ucx_dlist_clone(UcxDlist *l, copy_func fnc, void *data) {
+    UcxDlist *ret = NULL;
+    while (l != NULL) {
+        if (fnc != NULL) {
+            ret = ucx_dlist_append(ret, fnc(l->data, data));
+        } else {
+            ret = ucx_dlist_append(ret, l->data);
+        }
+        l = l->next;
+    }
+    return ret;
+}
+
+int ucx_dlist_equals(UcxDlist *l1, UcxDlist *l2, cmp_func fnc, void* data) {
+    if (l1 == l2) return 1;
+    
+    while (l1 != NULL && l2 != NULL) {
+        if (fnc == NULL) {
+            if (l1->data != l2->data) return 0;
+        } else {
+            if (fnc(l1->data, l2->data, data) != 0) return 0;
+        }
+        l1 = l1->next;
+        l2 = l2->next;
+    }
+    
+    return (l1 == NULL && l2 == NULL);
+}
+
 void ucx_dlist_free(UcxDlist *l) {
     UcxDlist *e = l, *f;
     while (e != NULL) {
@@ -12,7 +41,7 @@
 UcxDlist *ucx_dlist_append(UcxDlist *l, void *data)  {
     UcxDlist *nl = (UcxDlist*) malloc(sizeof(UcxDlist));
     if (nl == NULL) return NULL;
-
+    
     nl->data = data;
     nl->next = NULL;
     if (l == NULL) {
@@ -28,7 +57,7 @@
 UcxDlist *ucx_dlist_prepend(UcxDlist *l, void *data) {
     UcxDlist *nl = ucx_dlist_append(NULL, data);
     if (nl == NULL) return NULL;
-
+    
     if (l != NULL) {
         nl->next = l;
         l->prev = nl;
@@ -49,7 +78,7 @@
 
 UcxDlist *ucx_dlist_last(UcxDlist *l) {
     if (l == NULL) return NULL;
-
+    
     UcxDlist *e = l;
     while (e->next != NULL) {
         e = e->next;
@@ -65,13 +94,13 @@
         e = e->next;
         index--;
     }
-
+    
     return index == 0 ? e : NULL;
 }
 
 size_t ucx_dlist_size(UcxDlist *l) {
     if (l == NULL) return 0;
-
+    
     UcxDlist *e = l;
     size_t s = 1;
     while (e->next != NULL) {
@@ -93,7 +122,7 @@
 /* dlist specific functions */
 UcxDlist *ucx_dlist_first(UcxDlist *l) {
     if (l == NULL) return NULL;
-
+    
     UcxDlist *e = l;
     while (e->prev != NULL) {
         e = e->prev;
--- a/src/server/ucx/dlist.h	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/ucx/dlist.h	Sat Jan 14 14:33:38 2012 +0100
@@ -1,5 +1,5 @@
-/*
- *
+/* 
+ * 
  */
 
 #ifndef DLIST_H
@@ -19,6 +19,9 @@
     UcxDlist *prev;
 };
 
+UcxDlist *ucx_dlist_clone(UcxDlist *l, copy_func fnc, void* data);
+int ucx_dlist_equals(UcxDlist *l1, UcxDlist *l2, cmp_func fnc, void* data);
+
 void ucx_dlist_free(UcxDlist *l);
 UcxDlist *ucx_dlist_append(UcxDlist *l, void *data);
 UcxDlist *ucx_dlist_prepend(UcxDlist *l, void *data);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/server/ucx/list.c	Sat Jan 14 14:33:38 2012 +0100
@@ -0,0 +1,117 @@
+#include "list.h"
+
+UcxList *ucx_list_clone(UcxList *l, copy_func fnc, void *data) {
+    UcxList *ret = NULL;
+    while (l != NULL) {
+        if (fnc != NULL) {
+            ret = ucx_list_append(ret, fnc(l->data, data));
+        } else {
+            ret = ucx_list_append(ret, l->data);
+        }
+        l = l->next;
+    }
+    return ret;
+}
+
+int ucx_list_equals(UcxList *l1, UcxList *l2, cmp_func fnc, void* data) {
+    if (l1 == l2) return 1;
+    
+    while (l1 != NULL && l2 != NULL) {
+        if (fnc == NULL) {
+            if (l1->data != l2->data) return 0;
+        } else {
+            if (fnc(l1->data, l2->data, data) != 0) return 0;
+        }
+        l1 = l1->next;
+        l2 = l2->next;
+    }
+    
+    return (l1 == NULL && l2 == NULL);
+}
+
+void ucx_list_free(UcxList *l) {
+    UcxList *e = l, *f;
+    while (e != NULL) {
+        f = e;
+        e = e->next;
+        free(f);
+    }
+}
+
+UcxList *ucx_list_append(UcxList *l, void *data)  {
+    UcxList *nl = (UcxList*) malloc(sizeof(UcxList));
+    if (nl == NULL) return NULL;
+    
+    nl->data = data;
+    nl->next = NULL;
+    if (l == NULL) {
+        return nl;
+    } else {
+        UcxList *t = ucx_list_last(l);
+        t->next = nl;
+        return l;
+    }
+}
+
+UcxList *ucx_list_prepend(UcxList *l, void *data) {
+    UcxList *nl = ucx_list_append(NULL, data);
+    if (nl == NULL) return NULL;
+    
+    if (l != NULL) {
+        nl->next = l;
+    }
+    return nl;
+}
+
+UcxList *ucx_list_concat(UcxList *l1, UcxList *l2) {
+    if (l1 == NULL) {
+        return l2;
+    } else {
+        UcxList *last = ucx_list_last(l1);
+        last->next = l2;
+        return l1;
+    }
+}
+
+UcxList *ucx_list_last(UcxList *l) {
+    if (l == NULL) return NULL;
+    
+    UcxList *e = l;
+    while (e->next != NULL) {
+        e = e->next;
+    }
+    return e;
+}
+
+UcxList *ucx_list_get(UcxList *l, int index) {
+    if (l == NULL) return NULL;
+
+    UcxList *e = l;
+    while (e->next != NULL && index > 0) {
+        e = e->next;
+        index--;
+    }
+    
+    return index == 0 ? e : NULL;
+}
+
+size_t ucx_list_size(UcxList *l) {
+    if (l == NULL) return 0;
+    
+    UcxList *e = l;
+    size_t s = 1;
+    while (e->next != NULL) {
+        e = e->next;
+        s++;
+    }
+
+    return s;
+}
+
+void ucx_list_foreach(UcxList *l, ucx_callback fnc, void* data) {
+    UcxList *e = l;
+    while (e != NULL) {
+        fnc(e, data);
+        e = e->next;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/server/ucx/list.h	Sat Jan 14 14:33:38 2012 +0100
@@ -0,0 +1,39 @@
+/*
+ * 
+ */
+
+#ifndef LIST_H
+#define	LIST_H
+
+#include "ucx.h"
+#include <stddef.h>
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+typedef struct UcxList UcxList;
+struct UcxList {
+    void    *data;
+    UcxList *next;
+};
+
+UcxList *ucx_list_clone(UcxList *l, copy_func fnc, void *data);
+int ucx_list_equals(UcxList *l1, UcxList *l2, cmp_func fnc, void *data);
+
+void ucx_list_free(UcxList *l);
+UcxList *ucx_list_append(UcxList *l, void *data);
+UcxList *ucx_list_prepend(UcxList *l, void *data);
+UcxList *ucx_list_concat(UcxList *l1, UcxList *l2);
+UcxList *ucx_list_last(UcxList *l);
+UcxList *ucx_list_get(UcxList *l, int index);
+size_t ucx_list_size(UcxList *l);
+void ucx_list_foreach(UcxList *l, ucx_callback fnc, void *data);
+
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* LIST_H */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/server/ucx/map.c	Sat Jan 14 14:33:38 2012 +0100
@@ -0,0 +1,118 @@
+/*
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "map.h"
+
+UcxMap *ucx_map_new(size_t size) {
+    UcxMap *map = (UcxMap*)malloc(sizeof(UcxMap));
+    if(map == NULL) {
+        return NULL;
+    }
+
+    map->map = (UcxMapElement*)calloc(size, sizeof(UcxMapElement));
+    if(map->map == NULL) {
+        free(map);
+        return NULL;
+    }
+    map->size = size;
+
+    return map;
+}
+
+int ucx_map_put(UcxMap *map, UcxKey key, void *data) {
+    if(key.hash == 0) {
+        key.hash = ucx_hash((char*)key.data, key.len);
+    }
+    void *kd = malloc(key.len);
+    memcpy(kd, key.data, key.len);
+    key.data = kd;
+
+    UcxMapElement *elm = &map->map[key.hash%map->size];
+    if(elm->next != NULL) {
+        while(elm->next != NULL) {
+            elm = elm->next;
+        }
+        UcxMapElement *e = (UcxMapElement*)malloc(sizeof(UcxMapElement));
+        if(e == NULL) {
+            return -1;
+        }
+        elm->next = e;
+        elm = e;
+    }
+
+    elm->key = key;
+    elm->data = data;
+
+    return 0;
+}
+
+void* ucx_map_get(UcxMap *map, UcxKey key) {
+    if(key.hash == 0) {
+        key.hash = ucx_hash((char*)key.data, key.len);
+    }
+    
+    UcxMapElement *elm = &map->map[key.hash%map->size];
+    while(elm != NULL) {
+        if(elm->key.hash == key.hash) {
+            int n = (key.len > elm->key.len) ? elm->key.len : key.len;
+            if(memcmp(elm->key.data, key.data, n) == 0) {
+                return elm->data;
+            }
+        }
+        elm = elm->next;
+    }
+
+    return NULL;
+}
+
+UcxKey ucx_key(void *data, size_t len) {
+    UcxKey key;
+    key.data = data;
+    key.len = len;
+    key.hash = ucx_hash(data, len);
+    return key;
+}
+
+
+int ucx_hash(char *data, size_t len) {
+    /* murmur hash 2 */
+
+    int m = 0x5bd1e995;
+    int r = 24;
+
+    int h = 25 ^ len;
+
+    int i = 0;
+    while (len >= 4) {
+        int k = data[i + 0] & 0xFF;
+        k |= (data[i + 1] & 0xFF) << 8;
+        k |= (data[i + 2] & 0xFF) << 16;
+        k |= (data[i + 3] & 0xFF) << 24;
+
+        k *= m;
+        k ^= k >> r;
+        k *= m;
+
+        h *= m;
+        h ^= k;
+
+        i += 4;
+        len -= 4;
+    }
+
+    switch (len) {
+        case 3: h ^= (data[i + 2] & 0xFF) << 16;
+        case 2: h ^= (data[i + 1] & 0xFF) << 8;
+        case 1: h ^= (data[i + 0] & 0xFF); h *= m;
+    }
+
+    h ^= h >> 13;
+    h *= m;
+    h ^= h >> 15;
+
+    return h;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/server/ucx/map.h	Sat Jan 14 14:33:38 2012 +0100
@@ -0,0 +1,56 @@
+/*
+ * 
+ */
+
+#ifndef MAP_H
+#define	MAP_H
+
+#include "ucx.h"
+#include "string.h"
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+typedef struct UcxMap        UcxMap;
+typedef struct UcxKey        UcxKey;
+typedef struct UcxMapElement UcxMapElement;
+
+struct UcxMap {
+    UcxMapElement *map;
+    size_t        size;
+};
+
+struct UcxKey {
+    void   *data;
+    size_t len;
+    int    hash;
+};
+
+struct UcxMapElement {
+    void          *data;
+    UcxMapElement *next;
+    UcxKey        key;
+};
+
+
+UcxMap *ucx_map_new(size_t size);
+
+int ucx_map_put(UcxMap *map, UcxKey key, void *data);
+void* ucx_map_get(UcxMap *map, UcxKey key);
+
+#define ucx_map_sstr_put(m, s, d) ucx_map_put(m, ucx_key(s.ptr, s.length), d)
+#define ucx_map_cstr_put(m, s, d) ucx_map_put(m, ucx_key(s, strlen(s)), d)
+#define ucx_map_sstr_get(m, s) ucx_map_get(m, ucx_key(s.ptr, s.length))
+#define ucx_map_cstr_get(m, s) ucx_map_get(m, ucx_key(s, strlen(s)))
+
+UcxKey ucx_key(void *data, size_t len);
+
+int ucx_hash(char *data, size_t len);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* MAP_H */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/server/ucx/mempool.c	Sat Jan 14 14:33:38 2012 +0100
@@ -0,0 +1,119 @@
+/*
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "mempool.h"
+
+typedef struct {
+    ucx_destructor destructor;
+    char c;
+} ucx_memchunk;
+
+typedef struct {
+    ucx_destructor destructor;
+    void           *ptr;
+} ucx_regdestr;
+
+void ucx_mempool_shared_destr(void* ptr) {
+    ucx_regdestr *rd = (ucx_regdestr*)ptr;
+    rd->destructor(rd->ptr);
+}
+
+UcxMempool *ucx_mempool_new(size_t n) {
+    UcxMempool *pool = (UcxMempool*)malloc(sizeof(UcxMempool));
+    if (pool == NULL) return NULL;
+    
+    pool->data = malloc(n * sizeof(void*));
+    if (pool->data == NULL) {
+        free(pool);
+        return NULL;
+    }
+    
+    pool->ndata = 0;
+    pool->size = n;
+    return pool;
+}
+
+int ucx_mempool_chcap(UcxMempool *pool, size_t newcap) {
+    void **data = realloc(pool->data, newcap*sizeof(void*));
+    if (data == NULL) {
+        return ENOMEM;
+    } else {
+        pool->data = data; 
+        pool->size = newcap;
+        return EXIT_SUCCESS;
+    }
+}
+
+void *ucx_mempool_malloc(UcxMempool *pool, size_t n) {
+    ucx_memchunk *mem = (ucx_memchunk*)malloc(sizeof(ucx_destructor) + n);
+    if (mem == NULL) return NULL;
+
+    if (pool->ndata >= pool->size) {
+        ucx_mempool_chcap(pool, pool->size + 16);
+     }
+
+    mem->destructor = NULL;
+    pool->data[pool->ndata] = mem;
+    pool->ndata++;
+
+    return &mem->c;
+}
+
+void *ucx_mempool_calloc(UcxMempool *pool, size_t nelem, size_t elsize) {
+    void *ptr = ucx_mempool_malloc(pool, nelem*elsize);
+    if(ptr == NULL) {
+        return NULL;
+    }
+    memset(ptr, 0, nelem * elsize);
+    return ptr;
+}
+
+void *ucx_mempool_realloc(UcxMempool *pool, void *ptr, size_t n) {
+    void *mem = ((char*)ptr) - sizeof(ucx_destructor);
+    char *newm = (char*) realloc(mem, n + sizeof(ucx_destructor));
+    if (newm == NULL) return NULL;
+    if (mem != newm) {
+        for(int i=0;i<pool->ndata;i++) {
+            if(pool->data[i] == mem) {
+                pool->data[i] = newm;
+                return ((char*) newm) + sizeof(ucx_destructor);
+            }
+        }
+        fprintf(stderr, "FATAL: %8x not in mpool %8x\n", mem, pool);
+        exit(1);
+    } else {
+        return ((char*) newm) + sizeof(ucx_destructor);
+    }
+}
+
+void ucx_mempool_free(UcxMempool *pool) {
+    ucx_memchunk *chunk;
+    for(int i=0;i<pool->ndata;i++) {
+        chunk = (ucx_memchunk*) pool->data[i];
+        if(chunk->destructor != NULL) {
+            chunk->destructor(&chunk->c);
+        }
+        free(chunk);
+    }
+    free(pool->data);
+    free(pool);
+}
+
+void ucx_mempool_set_destr(void *ptr, ucx_destructor func) {
+    *(ucx_destructor*)((char*)ptr-sizeof(ucx_destructor)) = func;
+}
+
+void ucx_mempool_reg_destr(UcxMempool *pool, void *ptr, ucx_destructor destr) {
+    ucx_regdestr *rd = (ucx_regdestr*)ucx_mempool_malloc(
+            pool,
+            sizeof(ucx_regdestr));
+    rd->destructor = destr;
+    rd->ptr = ptr;
+    ucx_mempool_set_destr(rd, ucx_mempool_shared_destr);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/server/ucx/mempool.h	Sat Jan 14 14:33:38 2012 +0100
@@ -0,0 +1,39 @@
+/* 
+ *
+ */
+
+#ifndef MPOOL_H
+#define	MPOOL_H
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+typedef void(*ucx_destructor)(void*);
+
+typedef struct {
+    void   **data;
+    size_t ndata;
+    size_t size;
+} UcxMempool;
+
+#define ucx_mempool_new_default() ucx_mempool_new(16)
+UcxMempool *ucx_mempool_new(size_t n);
+int ucx_mempool_chcap(UcxMempool *pool, size_t newcap);
+
+void *ucx_mempool_malloc(UcxMempool *pool, size_t n);
+void *ucx_mempool_calloc(UcxMempool *pool, size_t nelem, size_t elsize);
+void *ucx_mempool_realloc(UcxMempool *pool, void *ptr, size_t n);
+
+void ucx_mempool_free(UcxMempool *pool);
+
+void ucx_mempool_set_destr(void *ptr, ucx_destructor func);
+void ucx_mempool_reg_destr(UcxMempool *pool, void *ptr, ucx_destructor destr);
+
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* MPOOL_H */
+
--- a/src/server/ucx/objs.mk	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/ucx/objs.mk	Sat Jan 14 14:33:38 2012 +0100
@@ -30,8 +30,11 @@
 
 UCX_OBJPRE = $(OBJ_DIR)$(UCX_SRC_DIR)
 
-UCXOBJ = dlist.o
-UCXOBJ += sstring.o
+UCXOBJ = list.o
+UCXOBJ += dlist.o
+UCXOBJ += map.o
+UCXOBJ += mempool.o
+UCXOBJ += string.o
 
 UCXOBJS = $(UCXOBJ:%=$(UCX_OBJPRE)%)
 
--- a/src/server/ucx/sstring.c	Sat Jan 14 13:53:44 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2011 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-
-#include "sstring.h"
-
-sstr_t sstr (char *s) {
-    sstr_t string;
-    if(s == NULL) {
-        string.length = 0;
-        string.ptr = NULL;
-    } else {
-        string.ptr = s;
-        string.length = strlen(s);
-    }
-    return string;
-}
-
-sstr_t sstrn (char *s, size_t n) {
-    sstr_t string;
-    string.ptr = s;
-    string.length = n;
-    return string;
-}
-
-size_t sstrnlen (size_t n, sstr_t s, ...) {
-    va_list ap;
-    size_t size = s.length;
-    va_start(ap, s);
-
-    for (int i=0;i<n-1;i++) {
-        sstr_t str = va_arg(ap, sstr_t);
-        size += str.length;
-    }
-
-    return size;
-}
-
-sstr_t sstrcat (sstr_t s, ...) {
-    va_list ap;
-    va_start(ap, s);
-    s.ptr[0] = 0;
-
-    sstr_t str = va_arg (ap, sstr_t);
-    while (str.ptr != NULL) {
-        s.ptr = strncat (s.ptr, str.ptr, s.length);
-        str = va_arg (ap, sstr_t);
-    }
-    
-    return s;
-}
-
-sstr_t sstrncat (size_t n, sstr_t s, sstr_t c1, ...) {
-    va_list ap;
-    va_start(ap, c1);
-    s.ptr[0] = 0;
-
-    s.ptr = strncat (s.ptr, c1.ptr, s.length);
-    for (int i=0;i<n-1;i++) {
-        sstr_t str = va_arg (ap, sstr_t);
-        s.ptr = strncat (s.ptr, str.ptr, s.length);
-    }
-
-    return s;
-}
-
-sstr_t sstrsubs (sstr_t s, size_t start) {
-    return sstrsubsl (s, start, s.length-start);
-}
-
-sstr_t sstrsubsl (sstr_t s, size_t start, size_t length) {
-    sstr_t new_sstr;
-    if (start < 0 || start >= s.length || length < 0) {
-        return s;
-    }
-    if (length > s.length-start) {
-        length = s.length-start;
-    }
-    new_sstr.ptr = &s.ptr[start];
-    new_sstr.length = length;
-    return new_sstr;
-}
-
-int sstrcmp(sstr_t s1, sstr_t s2) {
-    return strncmp(s1.ptr, s2.ptr, s1.length>s2.length ? s2.length: s1.length);
-}
-
-sstr_t sstrdub(sstr_t s) {
-    sstr_t newstring;
-    newstring.ptr = malloc(s.length + 1);
-    newstring.length = s.length;
-    newstring.ptr[newstring.length] = 0;
-
-    memcpy(newstring.ptr, s.ptr, s.length);
-
-    return newstring;
-}
--- a/src/server/ucx/sstring.h	Sat Jan 14 13:53:44 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2011 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _SSTRING_H
-#define	_SSTRING_H
-
-#define S(s) { s, sizeof(s)-1 }
-#define ST(s) sstrn(s, sizeof(s)-1)
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-typedef struct sstring {
-    char   *ptr;
-    size_t length;
-} sstr_t;
-
-/*
- * creates a new sstr_t from a null terminated string
- *
- * s  null terminated string
- */
-sstr_t sstr (char *s);
-
-/*
- * creates a new sstr_t from a string and length
- *
- * s  string
- * n  length of string
- */
-sstr_t sstrn (char *s, size_t n);
-
-
-/*
- * gets the length of n sstr_t strings
- *
- * n    number of strings
- * s    string
- * ...  strings
- */
-size_t sstrnlen (size_t n, sstr_t s, ...);
-
-
-/*
- * concatenates n strings
- *
- * n    number of strings
- * s    new string with enough memory allocated
- * ...  strings
- */
-sstr_t sstrncat (size_t n, sstr_t s, sstr_t c1, ...);
-
-
-/*
- * 
- */
-sstr_t sstrsubs (sstr_t s, size_t start);
-
-/*
- * 
- */
-sstr_t sstrsubsl (sstr_t s, size_t start, size_t end);
-
-
-int sstrcmp(sstr_t s1, sstr_t s2);
-
-sstr_t sstrdub(sstr_t s);
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* _SSTRING_H */
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/server/ucx/string.c	Sat Jan 14 14:33:38 2012 +0100
@@ -0,0 +1,99 @@
+/*
+ * File:   sstring.c
+ * Author: olaf
+ *
+ * Created on 17. Juni 2010, 13:27
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "string.h"
+
+sstr_t sstr (char *s) {
+    sstr_t string;
+    string.ptr = s;
+    string.length = strlen(s);
+    return string;
+}
+
+sstr_t sstrn (char *s, size_t n) {
+    sstr_t string;
+    string.ptr = s;
+    string.length = n;
+    return string;
+}
+
+size_t sstrnlen (size_t n, sstr_t s, ...) {
+    va_list ap;
+    size_t size = s.length;
+    va_start(ap, s);
+
+    for (int i=0;i<n-1;i++) {
+        sstr_t str = va_arg(ap, sstr_t);
+        size += str.length;
+    }
+
+    return size;
+}
+
+sstr_t sstrcat (sstr_t s, ...) {
+    va_list ap;
+    va_start(ap, s);
+    s.ptr[0] = 0;
+
+    sstr_t str = va_arg (ap, sstr_t);
+    while (str.ptr != NULL) {
+        s.ptr = strncat (s.ptr, str.ptr, s.length);
+        str = va_arg (ap, sstr_t);
+    }
+
+    return s;
+}
+
+sstr_t sstrncat (size_t n, sstr_t s, sstr_t c1, ...) {
+    va_list ap;
+    va_start(ap, c1);
+    s.ptr[0] = 0;
+
+    s.ptr = strncat (s.ptr, c1.ptr, s.length);
+    for (int i=0;i<n-1;i++) {
+        sstr_t str = va_arg (ap, sstr_t);
+        s.ptr = strncat (s.ptr, str.ptr, s.length);
+    }
+
+    return s;
+}
+
+sstr_t sstrsubs (sstr_t s, size_t start) {
+    return sstrsubsl (s, start, s.length-start);
+}
+
+sstr_t sstrsubsl (sstr_t s, size_t start, size_t length) {
+    sstr_t new_sstr;
+    if (start < 0 || start >= s.length || length < 0) {
+        return s;
+    }
+    if (length > s.length-start) {
+        length = s.length-start;
+    }
+    new_sstr.ptr = &s.ptr[start];
+    new_sstr.length = length;
+    return new_sstr;
+}
+
+int sstrcmp(sstr_t s1, sstr_t s2) {
+    return strncmp(s1.ptr, s2.ptr, s1.length>s2.length ? s2.length: s1.length);
+}
+
+sstr_t sstrdub(sstr_t s) {
+    sstr_t newstring;
+    newstring.ptr = malloc(s.length + 1);
+    newstring.length = s.length;
+    newstring.ptr[newstring.length] = 0;
+
+    memcpy(newstring.ptr, s.ptr, s.length);
+
+    return newstring;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/server/ucx/string.h	Sat Jan 14 14:33:38 2012 +0100
@@ -0,0 +1,78 @@
+/*
+ * File:   sstring.h
+ * Author: olaf
+ *
+ * Created on 17. Juni 2010, 13:26
+ */
+
+#ifndef _SSTRING_H
+#define	_SSTRING_H
+
+#define S(s) { s, sizeof(s)-1 }
+#define ST(s) sstrn(s, sizeof(s)-1)
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+typedef struct sstring {
+    char   *ptr;
+    size_t length;
+} sstr_t;
+
+/*
+ * creates a new sstr_t from a null terminated string
+ *
+ * s  null terminated string
+ */
+sstr_t sstr (char *s);
+
+/*
+ * creates a new sstr_t from a string and length
+ *
+ * s  string
+ * n  length of string
+ */
+sstr_t sstrn (char *s, size_t n);
+
+
+/*
+ * gets the length of n sstr_t strings
+ *
+ * n    number of strings
+ * s    string
+ * ...  strings
+ */
+size_t sstrnlen (size_t n, sstr_t s, ...);
+
+
+/*
+ * concatenates n strings
+ *
+ * n    number of strings
+ * s    new string with enough memory allocated
+ * ...  strings
+ */
+sstr_t sstrncat (size_t n, sstr_t s, sstr_t c1, ...);
+
+
+/*
+ *
+ */
+sstr_t sstrsubs (sstr_t s, size_t start);
+
+/*
+ *
+ */
+sstr_t sstrsubsl (sstr_t s, size_t start, size_t end);
+
+
+int sstrcmp(sstr_t s1, sstr_t s2);
+
+sstr_t sstrdub(sstr_t s);
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* _SSTRING_H */
--- a/src/server/ucx/ucx.h	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/ucx/ucx.h	Sat Jan 14 14:33:38 2012 +0100
@@ -1,4 +1,4 @@
-/*
+/* 
  * File:   ucx.h
  * Author: olaf
  *
@@ -14,8 +14,15 @@
 extern "C" {
 #endif
 
+/* source,data -> errno */
 typedef int(*ucx_callback)(void*,void*);
 
+/* element1,element2,custom data -> {-1,0,1} */
+typedef int(*cmp_func)(void*,void*,void*);
+
+/* element,custom data -> copy of element */
+typedef void*(*copy_func)(void*,void*);
+
 #ifdef	__cplusplus
 }
 #endif
--- a/src/server/util/list.c	Sat Jan 14 13:53:44 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,175 +0,0 @@
-/* 
- * File:   list.c
- * Author: olaf
- *
- * Created on 18. Dezember 2010, 11:23
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "list.h"
-
-/* add functions */
-sdlist_t* sdlist_add(sdlist_t *list, void *data) {
-    sdlist_t *elm = malloc(sizeof(sdlist_t));
-    elm->data = data;
-    elm->next = NULL;
-
-    return sdlist_addl(list, elm);
-}
-
-sdlist_t* sdlist_addl(sdlist_t *list, sdlist_t *l) {
-    if (list != NULL) {
-        sdlist_t *end = sdlist_getlast(list);
-        end->next = l;
-        return list;
-    } else {
-        return l;
-    }
-}
-
-
-
-/* remove functions */
-sdlist_t* sdlist_remove(sdlist_t *list, void *data) {
-    sdlist_t *s = list;
-
-    sdlist_t *prev = NULL;
-    while (list != NULL) {
-        if (list->data == data) {
-            sdlist_t *nl =  sdlist_remove_elm(s, prev, list);
-            free(list);
-            return nl;
-        }
-
-        prev = list;
-        list = list->next;
-    }
-
-    return s;
-}
-
-sdlist_t* sdlist_removei(sdlist_t *list, int index) {
-    sdlist_t *s = list;
-
-    sdlist_t *prev = NULL;
-    int i = 0;
-    while (list != NULL) {
-        if (i == index) {
-            sdlist_t *nl =  sdlist_remove_elm(s, prev, list);
-            free(list);
-            return nl;
-        }
-
-        prev = list;
-        list = list->next;
-        i++;
-    }
-
-    return s;
-}
-
-sdlist_t* sdlist_removel(sdlist_t *list, sdlist_t *l) {
-    sdlist_t *s = list;
-
-    sdlist_t *prev = NULL;
-    while (list != NULL) {
-        if (list == l) {
-            return sdlist_remove_elm(s, prev, list);
-        }
-
-        prev = list;
-        list = list->next;
-    }
-
-    return s;
-}
-
-
-sdlist_t *sdlist_remove_elm(sdlist_t *list, sdlist_t *prev, sdlist_t *elm) {
-    if (elm == NULL) {
-        return list;
-    }
-
-    if (prev == NULL) {
-        return elm->next;
-    }
-
-    prev->next = elm->next;
-
-    return list;
-}
-
-
-
-/* insert functions */
-void sdlist_insert(sdlist_t *elm, void *data) {
-    sdlist_t *newelm = malloc(sizeof(sdlist_t));
-    newelm->data = data;
-    sdlist_insertl(elm, newelm);
-}
-
-void sdlist_insertl(sdlist_t *elm, sdlist_t *l) {
-    if (elm == NULL || l == NULL) {
-        return;
-    }
-    
-    l->next = elm->next;
-    elm->next = l;
-}
-
-
-/* get functions */
-sdlist_t* sdlist_get(sdlist_t *list, void *data) {
-    while (list != NULL) {
-        if (list->data == data) {
-            return list;
-        }
-        list = list->next;
-    }
-    return NULL;
-}
-
-sdlist_t* sdlist_geti(sdlist_t *list, int index) {
-    for (int i=0;i<index;i++) {
-        if (list == NULL) {
-            return NULL;
-        }
-        list = list->next;
-    }
-    return list;
-}
-
-sdlist_t* sdlist_getlast(sdlist_t *list) {
-    while(list->next != NULL) {
-        list = list->next;
-    }
-    return list;
-}
-
-
-
-/* miscellaneous functions */
-size_t sdlist_length(sdlist_t *list) {
-    int i = 0;
-    while(list->next != NULL) {
-        list = list->next;
-        i++;
-    }
-    return i;
-}
-
-void sdlist_free(sdlist_t *elm) {
-    free(elm);
-}
-
-void sdlist_foreach(sdlist_t *list, sdlist_iterator_func f, void *data) {
-    while(list != NULL) {
-        int r = f(list, data);
-        if (r) {
-            return;
-        }
-        list = list->next;
-    }
-}
--- a/src/server/util/list.h	Sat Jan 14 13:53:44 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2011 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIST_H
-#define	LIST_H
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-typedef struct _util_slist sdlist_t;
-
-struct _util_slist {
-    void *data;
-    sdlist_t *next;
-};
-
-typedef int (*sdlist_iterator_func)(sdlist_t*, void*);
-
-
-/* single linked list */
-
-/*
- * sdlist_add/sdllist_addl
- *
- * append to the end of the list one element
- */
-sdlist_t* sdlist_add(sdlist_t *list, void *data);
-sdlist_t* sdlist_addl(sdlist_t *list, sdlist_t *l);
-    
-/*
- * sdlist_remove/sdlist_removei
- *
- * remove one element from the list and free the sdlist_t object
- * returns the first element of the new list
- */
-sdlist_t* sdlist_remove(sdlist_t *list, void *data);
-sdlist_t* sdlist_removei(sdlist_t *list, int index);
-
-/*
- * sdlist_removel
- *
- * remove element l from the list
- * returns the first element of the new list
- */
-sdlist_t* sdlist_removel(sdlist_t *list, sdlist_t *l);
-
-/*
- * removes one element from the list
- *
- * list:   list
- * prev:   previous to elm
- * elm:    element which should be removed
- *
- * returns the first element of the new list
- */
-sdlist_t *sdlist_remove_elm(sdlist_t *list, sdlist_t *prev, sdlist_t *elm);
-    
-
-/*
- * sdlist_insert
- *
- * insert one element after the element elm
- */
-void sdlist_insert(sdlist_t *elm, void *data);
-void sdlist_insertl(sdlist_t *elm, sdlist_t *l);
-
-sdlist_t* sdlist_get(sdlist_t *list, void *data);
-sdlist_t* sdlist_geti(sdlist_t *list, int index);
-sdlist_t* sdlist_getlast(sdlist_t *list);
-
-size_t sdlist_length(sdlist_t *list);
-void sdlist_free(sdlist_t *elm);
-void sdlist_foreach(sdlist_t *list, sdlist_iterator_func f, void *data);
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* LIST_H */
-
--- a/src/server/util/map.c	Sat Jan 14 13:53:44 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2011 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "map.h"
-
-hashmap_t* hashmap_new(size_t size) {
-    hashmap_t *map = malloc(sizeof(hashmap_t));
-    map->map = calloc(size, sizeof(sdlist_t));
-    map->len = size;
-
-    return map;
-}
-
-void hashmap_free(hashmap_t *map) {
-    for(int i=0;i<map->len;i++) {
-        sdlist_t *list = map->map[0];
-        while(list != NULL) {
-            hashmap_elm_t *elm = (hashmap_elm_t*)list->data;
-            free(elm->key.ptr);
-            sdlist_t *l = list;
-            list = list->next;
-            free(elm);
-            free(l);
-        }
-    }
-    free(map->map);
-    free(map);
-}
-
-
-void hashmap_put(hashmap_t *map, sstr_t key, void *value) {
-    int hash = hashmap_hash(key.ptr, key.length);
-
-    sdlist_t *list = map->map[hash%map->len];
-
-    sstr_t k = sstrdub(key);
-
-    hashmap_elm_t *elm = malloc(sizeof(hashmap_elm_t));
-    elm->data = value;
-    elm->hash = hash;
-    elm->key = k;
-
-    map->map[hash%map->len] = sdlist_add(list, elm);
-}
-
-void* hashmap_get(hashmap_t *map, sstr_t key) {
-    int hash = hashmap_hash(key.ptr, key.length);
-    sdlist_t *list = map->map[hash%map->len];
-    void *value = NULL;
-
-    while (list != NULL) {
-        hashmap_elm_t *elm = list->data;
-        if (elm->hash == hash &&
-                strncmp(key.ptr, elm->key.ptr, key.length) == 0) {
-            value = elm->data;
-            break;
-        }
-        list = list->next;
-    }
-
-    return value;
-}
-
-
-
-
-/* hash function */
-int hashmap_hash(char *data, size_t len) {
-    /* murmur hash 2 */
-
-    int m = 0x5bd1e995;
-    int r = 24;
-
-    int h = 25 ^ len;
-
-    int i = 0;
-    while (len >= 4) {
-        int k = data[i + 0] & 0xFF;
-        k |= (data[i + 1] & 0xFF) << 8;
-        k |= (data[i + 2] & 0xFF) << 16;
-        k |= (data[i + 3] & 0xFF) << 24;
-
-        k *= m;
-        k ^= k >> r;
-        k *= m;
-
-        h *= m;
-        h ^= k;
-
-        i += 4;
-        len -= 4;
-    }
-
-    switch (len) {
-        case 3: h ^= (data[i + 2] & 0xFF) << 16;
-        case 2: h ^= (data[i + 1] & 0xFF) << 8;
-        case 1: h ^= (data[i + 0] & 0xFF); h *= m;
-    }
-
-    h ^= h >> 13;
-    h *= m;
-    h ^= h >> 15;
-
-    return h;
-}
--- a/src/server/util/map.h	Sat Jan 14 13:53:44 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2011 Olaf Wintermann. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright
- *      notice, this list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright
- *      notice, this list of conditions and the following disclaimer in the
- *      documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MAP_H
-#define	MAP_H
-
-#include "list.h"
-#include "../ucx/sstring.h"
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-typedef struct _hashmap_elm {
-    int hash;
-    sstr_t key;
-
-    void *data;
-} hashmap_elm_t;
-
-typedef struct _util_hashmap {
-    sdlist_t **map;
-    size_t len;
-} hashmap_t;
-
-hashmap_t* hashmap_new(size_t size);
-void hashmap_free(hashmap_t *map);
-
-void hashmap_put(hashmap_t *map, sstr_t key, void *value);
-void* hashmap_get(hashmap_t *map, sstr_t key);
-
-int hashmap_hash(char *data, size_t len);
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* MAP_H */
-
--- a/src/server/util/objs.mk	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/util/objs.mk	Sat Jan 14 14:33:38 2012 +0100
@@ -31,8 +31,6 @@
 UTIL_OBJPRE = $(OBJ_DIR)$(UTIL_SRC_DIR)
 
 UTILOBJ = io.o
-UTILOBJ += list.o
-UTILOBJ += map.o
 UTILOBJ += netbuf.o
 UTILOBJ += object.o
 UTILOBJ += pblock.o
--- a/src/server/util/strbuf.c	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/util/strbuf.c	Sat Jan 14 14:33:38 2012 +0100
@@ -31,7 +31,7 @@
 #include <string.h>
 
 #include "strbuf.h"
-#include "../ucx/sstring.h"
+#include "../ucx/string.h"
 
 sbuf_t* sbuf_new(size_t size) {
     sbuf_t *buf = malloc(sizeof(sbuf_t));
--- a/src/server/util/strbuf.h	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/util/strbuf.h	Sat Jan 14 14:33:38 2012 +0100
@@ -29,7 +29,7 @@
 #ifndef STRBUF_H
 #define	STRBUF_H
 
-#include "../ucx/sstring.h"
+#include "../ucx/string.h"
 
 #ifdef	__cplusplus
 extern "C" {
--- a/src/server/webdav/saxhandler.cpp	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/webdav/saxhandler.cpp	Sat Jan 14 14:33:38 2012 +0100
@@ -30,7 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "../ucx/sstring.h"
+#include "../ucx/string.h"
 #include "../ucx/dlist.h"
 #include "../util/pool.h"
 
--- a/src/server/webdav/webdav.c	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/webdav/webdav.c	Sat Jan 14 14:33:38 2012 +0100
@@ -31,7 +31,7 @@
 #include <string.h>
 
 #include "webdav.h"
-#include "../ucx/sstring.h"
+#include "../ucx/string.h"
 #include "../util/pool.h"
 #include "../util/pblock.h"
 
--- a/src/server/webdav/webdav.h	Sat Jan 14 13:53:44 2012 +0100
+++ b/src/server/webdav/webdav.h	Sat Jan 14 14:33:38 2012 +0100
@@ -34,7 +34,7 @@
 #include <sys/file.h>
 #include <sys/stat.h>
 
-#include "../util/map.h"
+#include "../ucx/map.h"
 #include "../ucx/dlist.h"
 #include "../util/strbuf.h"
 

mercurial