From 5c23fd64ccc5936746ab0285799a735ac6f54f05 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 22 Apr 2017 11:18:10 +0200 Subject: [PATCH] Add M_CSTR_OPLIST oplist for const char * --- m-core.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/m-core.h b/m-core.h index 6da7470a..2bb653d9 100644 --- a/m-core.h +++ b/m-core.h @@ -861,6 +861,14 @@ m_core_hash (const void *str, size_t length) CLEAR(M_C(name, _clear)), \ TYPE(M_C(name, _t)) ) +/* OPLIST for 'const char *' (with NO memory allocation) */ +#define M_CSTR_HASH(s) (m_core_hash((s), strlen(s))) +#define M_CSTR_EQUAL(a,b) (strcmp((a),(b)) == 0) +#define M_CSTR_OPLIST (INIT(M_INIT_DEFAULT), INIT_SET(M_SET_DEFAULT), \ + SET(M_SET_DEFAULT), CLEAR(M_NOTHING_DEFAULT), \ + HASH(M_CSTR_HASH), EQUAL(M_CSTR_EQUAL), \ + TYPE(const char *) ) + /* From an oplist (...) return ... */ #define M_OPLIST_FLAT(...) __VA_ARGS__