diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-02-24 20:09:14 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-02-27 23:29:07 +0100 |
commit | 89515304e4eb81ff9eb65f3a582136fc658de139 (patch) | |
tree | 24b445c4aa5588772aa98f830f4646a738727810 /src/nvim/map.h | |
parent | 1d8e7683604828592bd41cdac5a351145cd93487 (diff) | |
download | rneovim-89515304e4eb81ff9eb65f3a582136fc658de139.tar.gz rneovim-89515304e4eb81ff9eb65f3a582136fc658de139.tar.bz2 rneovim-89515304e4eb81ff9eb65f3a582136fc658de139.zip |
os/env: use libuv v1.12 getenv/setenv API
- Minimum required libuv is now v1.12
- Because `uv_os_getenv` requires allocating, we must manage a map
(`envmap` in `env.c`) to maintain the old behavior of `os_getenv` .
- free() map-items after removal. khash.h does not make copies of
anything, so even its keys must be memory-managed by the caller.
closes #8398
closes #9267
Diffstat (limited to 'src/nvim/map.h')
-rw-r--r-- | src/nvim/map.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/nvim/map.h b/src/nvim/map.h index 0e4308b953..75ab64cca4 100644 --- a/src/nvim/map.h +++ b/src/nvim/map.h @@ -25,11 +25,15 @@ void map_##T##_##U##_free(Map(T, U) *map); \ U map_##T##_##U##_get(Map(T, U) *map, T key); \ bool map_##T##_##U##_has(Map(T, U) *map, T key); \ + T map_##T##_##U##_key(Map(T, U) *map, T key); \ U map_##T##_##U##_put(Map(T, U) *map, T key, U value); \ U *map_##T##_##U##_ref(Map(T, U) *map, T key, bool put); \ U map_##T##_##U##_del(Map(T, U) *map, T key); \ void map_##T##_##U##_clear(Map(T, U) *map); +// +// NOTE: Keys AND values must be allocated! khash.h does not make a copy. +// MAP_DECLS(int, int) MAP_DECLS(cstr_t, ptr_t) MAP_DECLS(ptr_t, ptr_t) @@ -43,6 +47,7 @@ MAP_DECLS(String, handle_T) #define map_free(T, U) map_##T##_##U##_free #define map_get(T, U) map_##T##_##U##_get #define map_has(T, U) map_##T##_##U##_has +#define map_key(T, U) map_##T##_##U##_key #define map_put(T, U) map_##T##_##U##_put #define map_ref(T, U) map_##T##_##U##_ref #define map_del(T, U) map_##T##_##U##_del @@ -52,7 +57,9 @@ MAP_DECLS(String, handle_T) #define pmap_free(T) map_free(T, ptr_t) #define pmap_get(T) map_get(T, ptr_t) #define pmap_has(T) map_has(T, ptr_t) +#define pmap_key(T) map_key(T, ptr_t) #define pmap_put(T) map_put(T, ptr_t) +/// @see pmap_del2 #define pmap_del(T) map_del(T, ptr_t) #define pmap_clear(T) map_clear(T, ptr_t) @@ -62,4 +69,6 @@ MAP_DECLS(String, handle_T) #define map_foreach_value(map, value, block) \ kh_foreach_value(map->table, value, block) +void pmap_del2(PMap(cstr_t) *map, const char *key); + #endif // NVIM_MAP_H |