evitar, durante consultas, criacao de nos nao encontrados.
This commit is contained in:
17
hash.c
17
hash.c
@@ -4,7 +4,7 @@
|
|||||||
** Luiz Henrique de Figueiredo - 17 Aug 90
|
** Luiz Henrique de Figueiredo - 17 Aug 90
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *rcs_hash="$Id: hash.c,v 2.1 1994/04/20 22:07:57 celes Exp celes $";
|
char *rcs_hash="$Id: hash.c,v 2.2 1994/07/19 21:27:18 celes Exp celes $";
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -212,6 +212,21 @@ Hash *lua_createarray (int nhash)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** If the hash node is present, return its pointer, otherwise return a
|
||||||
|
** static nil object
|
||||||
|
*/
|
||||||
|
Object *lua_hashget (Hash *t, Object *ref)
|
||||||
|
{
|
||||||
|
static Object nil_obj = {T_NIL, {NULL}};
|
||||||
|
Node *n;
|
||||||
|
int h = head (t, ref);
|
||||||
|
if (h < 0) return NULL;
|
||||||
|
n = present(t, ref, h);
|
||||||
|
if (n == NULL) return &nil_obj;
|
||||||
|
else return &n->val;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** If the hash node is present, return its pointer, otherwise create a new
|
** If the hash node is present, return its pointer, otherwise create a new
|
||||||
** node for the given reference and also return its pointer.
|
** node for the given reference and also return its pointer.
|
||||||
|
|||||||
3
hash.h
3
hash.h
@@ -2,7 +2,7 @@
|
|||||||
** hash.h
|
** hash.h
|
||||||
** hash manager for lua
|
** hash manager for lua
|
||||||
** Luiz Henrique de Figueiredo - 17 Aug 90
|
** Luiz Henrique de Figueiredo - 17 Aug 90
|
||||||
** $Id: hash.h,v 1.1 1993/12/17 18:41:19 celes Exp celes $
|
** $Id: hash.h,v 2.1 1994/04/20 22:07:57 celes Exp celes $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef hash_h
|
#ifndef hash_h
|
||||||
@@ -26,6 +26,7 @@ typedef struct Hash
|
|||||||
Hash *lua_createarray (int nhash);
|
Hash *lua_createarray (int nhash);
|
||||||
void lua_hashmark (Hash *h);
|
void lua_hashmark (Hash *h);
|
||||||
void lua_hashcollector (void);
|
void lua_hashcollector (void);
|
||||||
|
Object *lua_hashget (Hash *t, Object *ref);
|
||||||
Object *lua_hashdefine (Hash *t, Object *ref);
|
Object *lua_hashdefine (Hash *t, Object *ref);
|
||||||
void lua_next (void);
|
void lua_next (void);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user