From e7fcefb391981a4c5e113c47d07a5f26c242e8e8 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sun, 29 Mar 2020 00:49:36 +0100 Subject: [PATCH] * Dict supports INIT_WITH method too. --- m-core.h | 8 ++++++++ m-dict.h | 1 + 2 files changed, 9 insertions(+) diff --git a/m-core.h b/m-core.h index e3a4e3ad..70519401 100644 --- a/m-core.h +++ b/m-core.h @@ -2528,6 +2528,14 @@ m_core_hash (const void *str, size_t length) #define M_INIT_VAI_FUNC(d, a) \ M_PAIR_2 d (M_PAIR_1 d, a) +/* Initialize the container 'dest' as per 'oplist' + and fill it with the given VA arguments which are pair of (key,value) */ +#define M_INIT_KEY_VAI(oplist, dest, ...) \ + (void)(M_GET_INIT oplist (dest) , \ + M_MAP2_C(M_INIT_KEY_VAI_FUNC, (dest, M_GET_SET_KEY oplist) , __VA_ARGS__)) +#define M_INIT_KEY_VAI_FUNC(d, a) \ + M_PAIR_2 d (M_PAIR_1 d, M_PAIR_1 a, M_PAIR_2 a) + /************************************************************/ /********************* MEMORY handling **********************/ diff --git a/m-dict.h b/m-dict.h index 48b10ee2..147f4075 100644 --- a/m-dict.h +++ b/m-dict.h @@ -921,6 +921,7 @@ #define DICTI_OPLIST_P2(name, key_oplist, value_oplist) \ (INIT(M_C(name, _init)), \ INIT_SET(M_C(name, _init_set)), \ + INIT_WITH(API_1(M_INIT_KEY_VAI)), \ SET(M_C(name, _set)), \ CLEAR(M_C(name, _clear)), \ INIT_MOVE(M_C(name, _init_move)), \