From 036e325e8a8be79a364004128eb2e9a936c0b393 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 27 Feb 2018 01:00:05 +0300 Subject: Add script function for check is hash table exists. New script function: htexists. --- src/emap/init.c | 1 + src/emap/script_buildins.c | 6 ++++++ src/emap/script_buildins.h | 1 + 3 files changed, 8 insertions(+) diff --git a/src/emap/init.c b/src/emap/init.c index 85d9bc5..ecd0de9 100644 --- a/src/emap/init.c +++ b/src/emap/init.c @@ -181,6 +181,7 @@ HPExport void plugin_init (void) addScriptCommand("htclear", "i", htClear); addScriptCommand("htdelete", "i", htDelete); addScriptCommand("htsize", "i", htSize); + addScriptCommand("htexists", "i", htExists); addScriptCommand("htiterator", "i", htIterator); addScriptCommand("htinextkey", "i", htiNextKey); addScriptCommand("hticheck", "i", htiCheck); diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c index 520f16f..6359ff6 100644 --- a/src/emap/script_buildins.c +++ b/src/emap/script_buildins.c @@ -1965,6 +1965,12 @@ BUILDIN(htSize) return true; } +BUILDIN(htExists) +{ + int64 id = script_getnum(st, 2); + script_pushint(st, htreg->hashtable_exists(id)); +} + BUILDIN(htIterator) { int64 id = script_getnum(st, 2); diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h index 176feb0..2066432 100644 --- a/src/emap/script_buildins.h +++ b/src/emap/script_buildins.h @@ -80,6 +80,7 @@ BUILDIN(htPut); BUILDIN(htClear); BUILDIN(htDelete); BUILDIN(htSize); +BUILDIN(htExists); BUILDIN(htIterator); BUILDIN(htiNextKey); BUILDIN(htiCheck); -- cgit v1.2.3-70-g09d2