diff options
author | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-05-12 02:25:17 +0200 |
---|---|---|
committer | Eliseo Martínez <eliseomarmol@gmail.com> | 2014-05-15 20:46:01 +0200 |
commit | da51dc9cf202772f60bd2da975dbef257bd9237c (patch) | |
tree | 5c16b93238a153f55634e9323077f30c8133970c /src/map.c | |
parent | ffe61e5ba1721340ca51d56bae3ddaca415fb5bc (diff) | |
download | rneovim-da51dc9cf202772f60bd2da975dbef257bd9237c.tar.gz rneovim-da51dc9cf202772f60bd2da975dbef257bd9237c.tar.bz2 rneovim-da51dc9cf202772f60bd2da975dbef257bd9237c.zip |
Introduce nvim namespace: Move files.
Move files from src/ to src/nvim/.
- src/nvim/ becomes the new root dir for nvim executable sources.
- src/libnvim/ is planned to become root dir of the neovim library.
Diffstat (limited to 'src/map.c')
-rw-r--r-- | src/map.c | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/src/map.c b/src/map.c deleted file mode 100644 index 3e2bbe03e0..0000000000 --- a/src/map.c +++ /dev/null @@ -1,91 +0,0 @@ -#include <stdlib.h> -#include <stdbool.h> - -#include "map.h" -#include "map_defs.h" -#include "vim.h" -#include "memory.h" - -#include "lib/khash.h" - -typedef struct { - void *ptr; -} Value; - -KHASH_MAP_INIT_STR(Map, Value) - -struct map { - khash_t(Map) *table; -}; - -Map *map_new() -{ - Map *rv = xmalloc(sizeof(Map)); - rv->table = kh_init(Map); - return rv; -} - -void map_free(Map *map) -{ - kh_clear(Map, map->table); - kh_destroy(Map, map->table); - free(map); -} - -void *map_get(Map *map, const char *key) -{ - khiter_t k; - - if ((k = kh_get(Map, map->table, key)) == kh_end(map->table)) { - return NULL; - } - - return kh_val(map->table, k).ptr; -} - -bool map_has(Map *map, const char *key) -{ - return map_get(map, key) != NULL; -} - -void *map_put(Map *map, const char *key, void *value) -{ - int ret; - void *rv = NULL; - khiter_t k = kh_put(Map, map->table, key, &ret); - Value val = {.ptr = value}; - - if (!ret) { - // key present, return the current value - rv = kh_val(map->table, k).ptr; - kh_del(Map, map->table, k); - } - - kh_val(map->table, k) = val; - - return rv; -} - -void *map_del(Map *map, const char *key) -{ - void *rv = NULL; - khiter_t k; - - if ((k = kh_get(Map, map->table, key)) != kh_end(map->table)) { - rv = kh_val(map->table, k).ptr; - kh_del(Map, map->table, k); - } - - return rv; -} - -void map_foreach(Map *map, key_value_cb cb) -{ - const char *key; - Value value; - - kh_foreach(map->table, key, value, { - cb(map, (const char *)key, value.ptr); - }); -} - |