ucx/map.c

changeset 67
27e67e725d35
parent 53
e533c170bfb8
child 69
fb59270b1de3
     1.1 --- a/ucx/map.c	Thu Oct 11 08:42:56 2012 +0200
     1.2 +++ b/ucx/map.c	Thu Oct 11 11:42:31 2012 +0200
     1.3 @@ -44,7 +44,8 @@
     1.4      free(map);
     1.5  }
     1.6  
     1.7 -int ucx_map_copy(UcxMap *from, UcxMap *to, copy_func fnc, void *data) {
     1.8 +int ucx_map_copy(UcxMap *restrict from, UcxMap *restrict to,
     1.9 +        copy_func fnc, void *data) {
    1.10      UcxMapIterator i = ucx_map_iterator(from);
    1.11      void *value;
    1.12      UCX_MAP_FOREACH(value, i) {
    1.13 @@ -82,6 +83,7 @@
    1.14          }
    1.15          map->count = 0;
    1.16          ucx_map_copy(&oldmap, map, NULL, NULL);
    1.17 +        /* TODO: free the UcxMapElement list of oldmap */
    1.18      }
    1.19      return 0;
    1.20  }
    1.21 @@ -92,8 +94,8 @@
    1.22      }
    1.23  
    1.24      size_t slot = key.hash%map->size;
    1.25 -    UcxMapElement *elm = map->map[slot];
    1.26 -    UcxMapElement *prev = NULL;
    1.27 +    UcxMapElement *restrict elm = map->map[slot];
    1.28 +    UcxMapElement *restrict prev = NULL;
    1.29  
    1.30      while (elm != NULL && elm->key.hash < key.hash) {
    1.31          prev = elm;
    1.32 @@ -136,8 +138,8 @@
    1.33      }
    1.34      
    1.35      size_t slot = key.hash%map->size;
    1.36 -    UcxMapElement *elm = map->map[slot];
    1.37 -    UcxMapElement *pelm = NULL;
    1.38 +    UcxMapElement *restrict elm = map->map[slot];
    1.39 +    UcxMapElement *restrict pelm = NULL;
    1.40      while (elm && elm->key.hash <= key.hash) {
    1.41          if(elm->key.hash == key.hash) {
    1.42              int n = (key.len > elm->key.len) ? elm->key.len : key.len;
    1.43 @@ -180,7 +182,7 @@
    1.44  }
    1.45  
    1.46  
    1.47 -int ucx_hash(char *data, size_t len) {
    1.48 +int ucx_hash(const char *data, size_t len) {
    1.49      /* murmur hash 2 */
    1.50  
    1.51      int m = 0x5bd1e995;

mercurial