summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/hash.c b/hash.c
index 0b823092..143c6f55 100644
--- a/hash.c
+++ b/hash.c
@@ -4,7 +4,7 @@
4** Luiz Henrique de Figueiredo - 17 Aug 90 4** Luiz Henrique de Figueiredo - 17 Aug 90
5*/ 5*/
6 6
7char *rcs_hash="$Id: hash.c,v 2.1 1994/04/20 22:07:57 celes Exp celes $"; 7char *rcs_hash="$Id: hash.c,v 2.2 1994/07/19 21:27:18 celes Exp celes $";
8 8
9#include <string.h> 9#include <string.h>
10#include <stdlib.h> 10#include <stdlib.h>
@@ -213,6 +213,21 @@ Hash *lua_createarray (int nhash)
213 213
214 214
215/* 215/*
216** If the hash node is present, return its pointer, otherwise return a
217** static nil object
218*/
219Object *lua_hashget (Hash *t, Object *ref)
220{
221 static Object nil_obj = {T_NIL, {NULL}};
222 Node *n;
223 int h = head (t, ref);
224 if (h < 0) return NULL;
225 n = present(t, ref, h);
226 if (n == NULL) return &nil_obj;
227 else return &n->val;
228}
229
230/*
216** If the hash node is present, return its pointer, otherwise create a new 231** If the hash node is present, return its pointer, otherwise create a new
217** node for the given reference and also return its pointer. 232** node for the given reference and also return its pointer.
218** On error, return NULL. 233** On error, return NULL.