mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 16:08:36 +00:00
refactor(map): remove extra-allocating map_new/map_free functions
Note: the reason for removing them is not that there after this refactor is no use of them, but rather that having them available is an anti-pattern: they manange an _extra_ heap allocation which has nothing to do with the functionality of the map itself (khash manages the real buffers internally). In case there happens to be a reason to allocate the map structure itself later, this should be made explicit using xcalloc/xfree calls.
This commit is contained in:
@@ -54,19 +54,6 @@
|
||||
INITIALIZER_DECLARE(T, U, __VA_ARGS__); \
|
||||
__KHASH_IMPL(T##_##U##_map,, T, U, 1, T##_hash, T##_eq) \
|
||||
\
|
||||
Map(T, U) *map_##T##_##U##_new() \
|
||||
{ \
|
||||
Map(T, U) *rv = xcalloc(1, sizeof(Map(T, U))); \
|
||||
/* khash_t table member is zero-initialized */ \
|
||||
return rv; \
|
||||
} \
|
||||
\
|
||||
void map_##T##_##U##_free(Map(T, U) *map) \
|
||||
{ \
|
||||
kh_dealloc(T##_##U##_map, &map->table); \
|
||||
xfree(map); \
|
||||
} \
|
||||
\
|
||||
void map_##T##_##U##_destroy(Map(T, U) *map) \
|
||||
{ \
|
||||
kh_dealloc(T##_##U##_map, &map->table); \
|
||||
|
Reference in New Issue
Block a user